pom.xml配置如下:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.6</version>
<!-- <executions> <execution> <id>make-assembly</id> <phase>package</phase>
<goals> <goal>assemble</goal> </goals> </execution> </executions> -->
<!-- 相关的配置 -->
<configuration>
<!-- 生成配置文件路径 -->
<configurationDirectory>conf</configurationDirectory>
<!-- 配置文件原路径,默认为src/main/config -->
<configurationSourceDirectory>src/main/config</configurationSourceDirectory>
<copyConfigurationDirectory>true</copyConfigurationDirectory>
<includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
<repositoryLayout>flat</repositoryLayout>
<!-- 依赖包目录 -->
<repositoryName>lib</repositoryName>
<!-- 生成脚本的后缀 -->
<binFileExtensions>
<unix>.sh</unix>
</binFileExtensions>
<!-- 生成的包的目录 -->
<assembleDirectory>D:\××××-RELEASE</assembleDirectory>
<!-- 启动的主类 -->
<programs>
<program>
<mainClass>org.aurora.test.TestMain</mainClass>
<!-- 生成可执行脚本的名字 -->
<name>TestServer</name>
</program>
</programs>
</configuration>
</plugin>
</plugins>
</build>
在eclipse中右键pom.xml,Run As->maven build...在Goals中输入命令package appassembler:assemble,然后run就可以在相应的目录下看到生成的启动脚本,默认好像是生成Windows的.bat和Linux的.sh