spring boot项目打包插件使用配置如下
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<repositoryLayout>flat</repositoryLayout>
<repositoryName>lib</repositoryName>
<configurationDirectory>conf</configurationDirectory>
<copyConfigurationDirectory>true</copyConfigurationDirectory>
<configurationSourceDirectory>src/main/resources</configurationSourceDirectory>
<includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
<target>${project.build.directory}</target>
<daemons>
<daemon>
<id>${project.name}</id>
<mainClass>${project.runtime.main_class}</mainClass>
<platforms>
<platform>jsw</platform>
</platforms>
<wrapperLogFile>logs/${project.name}.log</wrapperLogFile>
<generatorConfigurations>
<generatorConfiguration>
<generator>jsw</generator>
<includes>
<include>macosx-universal-64</include>
<include>linux-x86-32</include>
<include>linux-x86-64</include>
<include>windows-x86-32</include>
<include>windows-x86-64</include>
</includes>
<configuration>
<property>
<name>configuration.directory.in.classpath.first</name>
<value>conf</value>
</property>
<property>
<name>set.default.REPO_DIR</name>
<value>lib</value>
</property>
<property>
<name>wrapper.ping.timeout</name>
<value>300</value>
</property>
<property>
<name>wrapper.startup.timeout</name>
<value>300</value>
</property>
</configuration>
</generatorConfiguration>
</generatorConfigurations>
<jvmSettings>
<initialMemorySize>${project.runtime.mem_init}</initialMemorySize>
<maxMemorySize>${project.runtime.mem_max}</maxMemorySize>
<extraArguments>
<extraArgument>-server</extraArgument>
<extraArgument>${project.runtime.javaagent}</extraArgument>
<extraArgument>-Dpinpoint.agentId=${project.name}</extraArgument>
<extraArgument>-Dpinpoint.applicationName=${project.name}</extraArgument>
<extraArgument>-Dapplication.version=${project.version}</extraArgument>
<extraArgument>--application.version=${project.version}</extraArgument>
</extraArguments>
</jvmSettings>
</daemon>
</daemons>
</configuration>
<executions>
<execution>
<id>generate-jsw-scripts</id>
<phase>package</phase>
<goals>
<goal>generate-daemons</goal>
<goal>create-repository</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<dependencies>
<dependency>
<groupId>com.gpay</groupId>
<artifactId>gpay-lang</artifactId>
<version>1.0.05</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptor>assembly/bin.xml</descriptor>
<!-- <descriptorRefs>
<descriptorRef>springbootpkger</descriptorRef>
</descriptorRefs>-->
</configuration>
</plugin>
由于这里用到了pinpoint,打完包之后会在target目录里找到wrapper.conf
# Java Additional Parameters
#wrapper.java.additional.1=
wrapper.java.additional.1=-server
wrapper.java.additional.2=-javaagent:%PP_PATH%
wrapper.java.additional.3=-Dpinpoint.agentId=XXXXX
wrapper.java.additional.4=-Dpinpoint.applicationName=XXXX
wrapper.java.additional.5=-Dapplication.version=1.1.2-SNAPSHOT
其中 wrapper.java.additional.2=-javaagent:%PP_PATH% 是作为pinpoint用的,由于本地环境没有配置,所以会去掉。
# Java Additional Parameters
#wrapper.java.additional.1=
wrapper.java.additional.1=-server
#wrapper.java.additional.2=-javaagent:%PP_PATH%
wrapper.java.additional.3=-Dpinpoint.agentId=XXXX
wrapper.java.additional.4=-Dpinpoint.applicationName=XXXXX
wrapper.java.additional.5=-Dapplication.version=1.1.2-SNAPSHOT
可是去掉之后,就发现 @Value("${application.version}")注解拿不到 值,后来把 wrapper.java.additional.2 放开,随便修改一下就可以了。
# Java Additional Parameters
#wrapper.java.additional.1=
wrapper.java.additional.1=-server
wrapper.java.additional.2=-Dpinpoint.agentId=XXXX
wrapper.java.additional.3=-Dpinpoint.agentId=XXXX
wrapper.java.additional.4=-Dpinpoint.applicationName=XXXXX
wrapper.java.additional.5=-Dapplication.version=1.1.2-SNAPSHOT
可以发现 wrapper启动是有顺序的,如果上一步参数如果没有加载,下面就不会进行了。