编程语言
首页 > 编程语言> > Maven打包程序成可执行jar

Maven打包程序成可执行jar

作者:互联网

 使用maven-jar-plugin和maven-dependency-plugin插件打包

<build>
	    <plugins>
	        <plugin>
	            <groupId>org.apache.maven.plugins</groupId>
	            <artifactId>maven-jar-plugin</artifactId>
	            <version>2.6</version>
	            <configuration>
	                <archive>
	                    <manifest>
	                        <addClasspath>true</addClasspath>
	                        <classpathPrefix>lib/</classpathPrefix>
	                        <mainClass>com.XXX.MavenPackJar.App</mainClass>
	                    </manifest>
	                </archive>
	            </configuration>
	        </plugin>
	        <plugin>
	            <groupId>org.apache.maven.plugins</groupId>
	            <artifactId>maven-dependency-plugin</artifactId>
	            <version>2.10</version>
	            <executions>
	                <execution>
	                    <id>copy</id>
	                    <phase>package</phase>
	                    <goals>
	                        <goal>copy-dependencies</goal>
	                    </goals>
	                    <configuration>
	                        <outputDirectory>
	                            ${project.build.directory}/lib
	                        </outputDirectory>
	                    </configuration>
	                </execution>
	            </executions>
	        </plugin>
	    </plugins>
	</build>

修改打包的主类 <mainClass>com.XXXX.MavenPackJar.App</mainClass>

标签:maven,lib,plugin,jar,Maven,plugins,成可,打包
来源: https://blog.csdn.net/qq_36168749/article/details/101373013