1.打包成bat
打包命令:mvn clean package appassembler:assemble
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>appassembler-maven-plugin</artifactId> <version>1.2.1</version> <configuration> <!-- 生成linux, windows两种平台的执行脚本 --> <platforms> <platform>windows</platform> <platform>unix</platform> </platforms> <!-- 根目录 --> <assembleDirectory>${project.build.directory}/mall</assembleDirectory> <!-- 打包的jar,以及maven依赖的jar放到这个目录里面 --> <repositoryName>lib</repositoryName> <!-- 可执行脚本的目录 --> <binFolder>bin</binFolder> <!-- 配置文件的目标目录 --> <configurationDirectory>conf</configurationDirectory> <!-- 拷贝配置文件到上面的目录中 --> <copyConfigurationDirectory>true</copyConfigurationDirectory> <!-- 从哪里拷贝配置文件 (默认src/main/config) --> <configurationSourceDirectory>src/main/resources</configurationSourceDirectory> <!-- lib目录中jar的存放规则,默认是${groupId}/${artifactId}的目录格式,flat表示直接把jar放到lib目录 --> <repositoryLayout>flat</repositoryLayout> <encoding>UTF-8</encoding> <logsDirectory>logs</logsDirectory> <tempDirectory>tmp</tempDirectory> <programs> <program> <!-- 启动类 --> <mainClass>net.test.App</mainClass> <jvmSettings> <extraArguments> <extraArgument>-server</extraArgument> <extraArgument>-Xmx2G</extraArgument> <extraArgument>-Xms2G</extraArgument> </extraArguments> </jvmSettings> </program> </programs> </configuration> </plugin>
2.打包成系统服务
打包命令:mvn clean package appassembler:generate-daemons
Usage: { console | start | stop | restart | status | dump }
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>appassembler-maven-plugin</artifactId> <version>1.2.1</version> <configuration> <!-- 根目录 --> <assembleDirectory>${project.build.directory}/mall</assembleDirectory> <!-- 打包的jar,以及maven依赖的jar放到这个目录里面 --> <repositoryName>lib</repositoryName> <!-- 可执行脚本的目录 --> <binFolder>bin</binFolder> <!-- 配置文件的目标目录 --> <configurationDirectory>conf</configurationDirectory> <!-- 拷贝配置文件到上面的目录中 --> <copyConfigurationDirectory>true</copyConfigurationDirectory> <!-- 从哪里拷贝配置文件 (默认src/main/config) --> <configurationSourceDirectory>src/main/resources</configurationSourceDirectory> <!-- lib目录中jar的存放规则,默认是${groupId}/${artifactId}的目录格式,flat表示直接把jar放到lib目录 --> <repositoryLayout>flat</repositoryLayout> <encoding>UTF-8</encoding> <logsDirectory>logs</logsDirectory> <tempDirectory>tmp</tempDirectory> <daemons> <daemon> <mainClass>net.test.App</mainClass> <platforms> <platform>jsw</platform> </platforms> <generatorConfigurations> <generatorConfiguration> <generator>jsw</generator> <includes> <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>wrapper.ping.timeout</name> <value>120</value> </property> <property> <name>set.default.REPO_DIR</name> <value>lib</value> </property> <property> <name>wrapper.logfile</name> <value>logs/wrapper.log</value> </property> </configuration> </generatorConfiguration> </generatorConfigurations> <jvmSettings> <!-- jvm参数 --> <systemProperties> <systemProperty>com.sun.management.jmxremote</systemProperty> <systemProperty>com.sun.management.jmxremote.port=1984</systemProperty> <systemProperty>com.sun.management.jmxremote.authenticate=false</systemProperty> <systemProperty>com.sun.management.jmxremote.ssl=false</systemProperty> </systemProperties> </jvmSettings> </daemon> </daemons> </configuration> </plugin>
注意:1.2.1没有id这个属性。