1. Add the configuration in the pom.xml file
<!--编译打包插件-->
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<!-->此处设置成主类的类全名<-->
<mainClass>com.TomAndersen.AppMain</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
2. Use Maven project tool Packager
-
Use Maven-Lifecycle-package assembly
-
Console output
3. Generate jar package
- After the package will succeed
src
at the same level directorytarget
folder generated with and without dependent dependent jar package, the package name prefix andartifactId
the same
- NOTE 1: If the package does not have dependencies jar, the procedure relies on the implementation of the local operating environment
- Note 2: If you use the jar package program depends band, the program does not rely on the local operating environment is executed, and only depends on the development environment