POM文件(pom.xml):
<?xml version="1.0" encoding="UTF-8"?> <!-- xml文档版本和编码方式 -->
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <!-- POM模型版本 -->
<groupId>com.juvenxu.mvnbook</groupId> <!-- 项目所属组 -->
<artifactId>hello-world</artifactId> <!-- 项目在组的唯一ID -->
<version>1.0-SNAPSHOT</version> <!-- 项目版本(快照) -->
<name>Maven Hello World Project</name> <!-- 项目名(非必须) -->
<dependencies>
<dependency> <!-- JUnit测试, 自动下载JUnit4.7-->
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope><!-- 依赖范围 -->
</dependency>
</dependencies>
<build>
<plugins> <!-- compiler支持Java5-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin> <!-- 生成可执行的jar文件-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.juvenxu.mvnbook.helloworld.HelloWorld</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
转载于:https://blog.51cto.com/4610383/1296933