The ultimate solution: java -cp xxxxx.jar package. The class where the main function is located;
Example: java -cp java_linux_dep_t-1.4-SNAPSHOT.jar com.test.run.MainEntry
Execute the command java -jar xxxxx.jar
Error 1: no main manifest attribute, in xxxxxxx.jar
Reason: main method not found
Solution: Add the following plug-in configuration in pom.xml ( the mainClass item needs to be modified according to its own class name; only need to write the class name, no need to add groupId and 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
Reason: The mainClass configuration mentioned above is wrong
Solution: Only the class name needs to be written in mainClass, no need to add groupId and artifactId! ! !