Maven 插件生成包含依赖的可执行jar

发布于 2017-02-20 / Java / 0条评论 / 1,388浏览

Maven 生成包含依赖的可执行jar

<plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <appendAssemblyId>false</appendAssemblyId> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <!-- 指定main函数所在的类 --> <manifest> <mainClass>com.denghb.dbhepler.client.DbHelperClient</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>assembly</goal> </goals> </execution> </executions> </plugin>

执行命令

mvn assembly:assembly

copy target/xxx.jar

双击或java -jar xxx.jar

评论
站长统计