终极解决方法:java -cp xxxxx.jar 包.main函数所在类;
例子:java -cp java_linux_dep_t-1.4-SNAPSHOT.jar com.test.run.MainEntry
执行指令 java -jar xxxxx.jar
错误1:no main manifest attribute, in xxxxxxx.jar
原因:找不到main方法
解决:在pom.xml中添加如下插件配置(其中mainClass项需要根据自己的类名进行修改;只需要写类名,不需要加groupId和artifactId !!!)
<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>这里只写main函数所在类名即可</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
错误2:Error: Could not find or load main class com.ab.java_linux_dep_t.main_entry
原因:上面说的mainClass配置错误
解决:mainClass中只需要写类名,不需要加groupId和artifactId !!!