maven-可执行jar包

maven有两种生成可执行jar包的插件,能够自动加载依赖包。分别为maven-assembly-plugin 和appassembler-maven-plugin,appassembler-maven-plugin 的优势是能够自动生成window和linux的启动脚本,maven-assembly-plugin 生成jar包后需要执行 java -jar **.jar命令运行jar包。



appassembler-maven-plugin在pom.xml中配置:  

<plugin> 
                 <groupId>org.codehaus.mojo</groupId> 
                 <artifactId>appassembler-maven-plugin</artifactId> 
                 <version>1.1.1</version> 
                 <configuration> 
                    <programs> 
                      <program> 
                       <mainClass>com.smart4j.Smart4j.App</mainClass> 
                       <name>start</name> 
                      </program> 
                    </programs> 
                  </configuration> 
   </plugin>  
命令行切换到pom.xml同级目录,执行:

    mvn package appassembler:assemble

你可能感兴趣的:(java,maven,jar,plugin)