https://blog.csdn.net/javarrr/article/details/88911998
2 Recommendation: Use maven-assembly-plugin
(1) Add the following plugins to the pom.xml file of the project:
<build>
<plugins>
<!-- Maven Assembly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>com.healchow.consumer.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<!-- 配置执行器 -->
<execution>
<id>make-assembly</id>
<!-- 绑定到package命令的生命周期上 -->
<phase>package</phase>
<goals>
<!-- 只运行一次 -->
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
(2) Then use Maven's package command to package the project;
(3) After the packaging is completed, you can see the generated jar package in the target directory of the project, where xxx-jar-with-dependencies.jar is a jar file that contains the dependent jar package, and the other does not contain the dependent jar package;
(4) Use the java -jar xxxx.jar command to run the jar package.
3 Extension: Maven installs the local jar package to the local warehouse.
The command is as follows:
mvn install:install-file -Dfile=base-util-1.0.RELEASE.jar -DgroupId=com.healchow -DartifactId=base-util -Dversion=1.0.RELEASE -Dpackaging=jar