Quick packaging and deployment of springboot

Key knowledge points:

Maven's assembly plug-in implements custom packaging deployment (including dependent jar packages)

At present, there are several common deployment methods of spring boot project.

1. Use the docker container to deploy, build the application of springboot into a docker image, and then start the image through the container. This method is very convenient when large-scale application and application expansion need to be deployed. It belongs to the current industrial level deployment scheme, but it needs to master the ecosystem technology of docker.


2. Use fatjar to deploy and start directly, which is a simple application deployment method for many beginners or small-scale situations.  

Maven shade plugin, which is used to print executable JAR package, also known as fat JAR package;

3. Packaging with Maven assembly plugin plug-in is also one of the most widely deployed operation and maintenance methods at present, because there are many shell scripts, SQL scripts,. properties and. xml configuration items in big data projects. Using assembly plugin can make the output structure clear and standardized.


So go straight to the subject

To configure



                        <!-- Add to index Not from mainfest Read in classpath,But from Index.list Read in -->
                        <!--<index>true</index> -->
                            <!--Startup class main Method-->
                            <!-- Whether to specify classthpath-->
                            <!--For the following<Class-Path>add prefix,The default is empty.,'./'Is the current directory-->
                        <!-- Bound to package Life cycle stage -->
                            <!-- Bound to package Life cycle stage -->
                            <!--Configuration description file path-->
                            <descriptors> <!--Description file path-->


In the above configuration, there are Maven jar plugin default packaging plug-ins. skipTest packaging skips testing. The main configuration is




Assembly configuration

Structure catalog

xml configuration

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd
http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 ">
    <id>${project.version}</id><!--id Identifier, a suffix added to the name of the build file. Can not be specified-->

        <!--Packaging method,Support writing multiple include(zip,tar,tar.gz (or tgz),tar.bz2 (or tbz2),jar,dir,war)-->
        <!-- fileSet Mapping relationship between project path and packaged relative path-->

        <!--Will all resources The files under files are packed in conf Directory-->
        <!--Package startup scripts in bin Directory-->
        <!--You can also initialize sql The files are packed in init Directory-->


            <!-- take scope by runtime The dependency package of is packaged into lib Under the directory. -->



bin script command


nohup java -jar ../lib/demo-0.1.0-SNAPSHOT.jar >/dev/null 2>&1 &
echo $! > /var/run/demo.pid


PID=$(cat /var/run/demo.pid)
kill -9 $PID


Package success


After the package is successful, we can upload the tag package directly to the linux server

Deployment process

Upload tag Package >

Keywords: Programming Maven Apache xml Docker

Added by ozestretch on Tue, 11 Feb 2020 15:15:00 +0200