1 新建一个MAVEN项目
2 pom.xml
3 pom.xml目录下运行
mvn jar:jar
4 运行 java -jar test.jar
会打印MAIN CLASS
更多请看http://maven.apache.org/plugins/maven-jar-plugin/plugin-info.html
2 pom.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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.dean</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<!-- jar包入口 -->
<mainClass>test.Shuzu</mainClass>
<addClasspath>true</addClasspath>
</manifest>
<!-- 不打包pom.xml -->
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<finalName>test</finalName>
</configuration>
</plugin>
</plugins>
</build>
</project>
3 pom.xml目录下运行
mvn jar:jar
4 运行 java -jar test.jar
会打印MAIN CLASS
更多请看http://maven.apache.org/plugins/maven-jar-plugin/plugin-info.html