首页 > 代码库 > maven install 打包可运行jar

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