By default, SpringBoot project is packaged into a JAR package, which is not friendly in multiple environments. It is necessary to package the dependent third-party JAR and configuration files in the Resources directory into the same directory as the JAR package to facilitate environment changes. The specific operations are as follows:

Package to an external directory

  1. Pom. XML needs to modify

    <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <appendAssemblyId>false</appendAssemblyId> <descriptors> <descriptor>src/main/assembly/assembly.xml</descriptor> </descriptors> <outputDirectory>${project.build.directory}/gwall/</outputDirectory> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> <! -- Pack into a JAR file, And specify the lib folder and the resources folder --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>com.xxl.job.admin.XxlJobAdminApplication</mainClass> <! -- dependencies --> <classpathPrefix>lib/</classpathPrefix> <addClasspath>true</addClasspath> </manifest> < manifestmanifestentries > <Class-Path>resources/</Class-Path> </manifestEntries> </archive> </configuration> </plugin> </plugins> </build>
  2. Add configuration file



    The assembly. XML file has the following contents:

    < the assembly XMLNS = "http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Xsi: schemaLocation = "HTTP: / / http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd "> < id > distribution < id > <! > <format>tar.gz</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <! --> <fileSets> <fileSet> <directory> SRC /main/bin</directory> <outputDirectory>/</outputDirectory> <fileMode>0755</fileMode> </fileSet> <fileSet> <directory>src/main/resources/</directory> <outputDirectory>/resources</outputDirectory> <fileMode>0644</fileMode> </fileSet> </fileSets> <dependencySets> <dependencySet> <! > <outputDirectory>/lib</outputDirectory> <scope>runtime</scope> < lower class, lower class > <exclude>${project.groupId}:${project.artifactId}</exclude> </excludes> </dependencySet> <dependencySet> <! --> <outputDirectory>/</outputDirectory> <includes> <include>${project.groupId}:${project.artifactId}</include> </includes> </dependencySet> </dependencySets></assembly>

    The start.sh file is as follows:

    #! / bin/bash curpath = ` PWD ` app = XXL - job - admin - 2.1.0. Jar echo 'curpath: $curpath app: $app' ps - aux | grep $curpath / $app | grep -v grep|awk '{print $2}'|xargs -r kill -9 nohup java -jar $curpath/$app > $curpath/nohup.out 2>&1 &

    The start.bat file is as follows:

    @echo off & setLocal EnableDelayedExpansion java-jar xxl-job-admin-2.1.0.jar Pause

    The final result is as follows:





    Pay attention to the problem

    Logback is not effective

    This is mainly done using logback-spring.xml and is configured in Application.yml

     logging:
       config: config/logback-spring.xml

    See also: https://my.oschina.net/u/2022…