<plugin> <artifactId> maven-assembly-plugin </artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>com.cetc.di.App</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin>
<mainClass>com.cetc.di.App</mainClass> 声明的是 java -jar ****.jar运行时的主方法
关于此显示声明主方法的文件在 jar包解压出来的 ..\META-INF\MANIFEST.MF 里面显示声明直接执行时的主方法
如:Main-Class: com.corundumstudio.socketio.demo.ChatLauncher
若 jar包里还有其他main方法 运行这样的命令(windows环境)
如:java -classpath .\demo-1.0.0-SNAPSHOT-jar-with-dependencies.jar com.corundumstudio.socketio.demo.NamespaceChatLauncher
包名-------------------------->包含要执行的main方法的类名
原文:http://www.cnblogs.com/LiuPan2016/p/7816889.html