maven install 打包可运行jar

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了maven install 打包可运行jar相关的知识,希望对你有一定的参考价值。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>com.cn</groupId>
		<artifactId>system</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
	<build>
		<!-- 打包资源文件 -->
		<resources>
<!-- 			<resource> -->
<!-- 				打包后存放的位置 -->
<!--				<targetPath>${project.build.directory}/classes/spring</targetPath> -->
<!-- 				资源文件来源位置 -->
<!-- 				<directory>src/main/resources/spring</directory> -->
<!-- 				<filtering>true</filtering> -->
<!-- 				包含的文件类型 -->
<!-- 				<includes> -->
<!-- 					<include>*.xml</include> -->
<!-- 				</includes> -->
<!-- 				过滤的文件类型 -->
<!-- 				<excludes> -->
<!-- 				</excludes> -->
<!-- 			</resource> -->
			<resource>
				<targetPath>${project.build.directory}/classes</targetPath>
				<directory>src/main/resources</directory>
				<filtering>true</filtering>
				<includes>
					<include>*.xml</include>
					<include>*.properties</include>
				</includes>
			</resource>
			<resource>
				<targetPath>${project.build.directory}/classes/META-INF</targetPath>
				<directory>src/main/resources/META-INF</directory>
				<filtering>true</filtering>
				<includes>
					<include>**/*.*</include>
				</includes>
			</resource>
			<resource>
				<directory>src/main/resources</directory>
				<includes>
					<include>**/*.properties</include>
					<include>**/*.xml</include>
				</includes>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
				<version>2.4</version>
				<configuration>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>2.3</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
						<configuration>
							<transformers>
								<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
									<resource>META-INF/spring.handlers</resource>
								</transformer>
								<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
									<resource>META-INF/spring.schemas</resource>
								</transformer>
								<!-- 打包jar文件时,配置manifest文件,加入程序入口mainClass -->
								<transformer
									implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
									<mainClass>com.cn.main.ProgramMain</mainClass>
								</transformer>
							</transformers>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

	<artifactId>system-netty</artifactId>
</project>


本文出自 “青葱岁月” 博客,请务必保留此出处http://alex233.blog.51cto.com/8904951/1861168

以上是关于maven install 打包可运行jar的主要内容,如果未能解决你的问题,请参考以下文章

maven的两种可运行jar打包方式。1内置依赖,2外部依赖。

maven 打包可运行jar包

maven 可运行 jar 包的打包,包含依赖 jar 包

maven 可运行 jar 包的打包,包含依赖 jar 包

Maven学习Maven打包生成普通jar包可运行jar包包含所有依赖的jar包

如何使用maven把项目及其依赖打包为可运行jar包