直入正题:
POM文件中配置
方法一:
<build>
<finalName>entrance</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>packname.classname</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project><!-- 结束 -->
方法二:https://www.jianshu.com/p/7a0e20b30401
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>packname.classname</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build><!-- 结束 -->
笔者就了解这两种方法,欢迎提供其他方法。