<build> <finalName>你的包名</finalName> <plugins> <!-- Maven Shade Plugin 用于将所有依赖打包到一个 JAR 中 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <!-- 指定主类 --> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>com.你的主启动类,也就是程序入口</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> <!-- Maven Compiler Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>
将上面这段替换你的pom打包插件配置
原因无非是
1,jar包中的MANIFEST.MF没有指定mainClass,报jar中没有主清单属性
2,程序需要的lib依赖没有打入,运行需要时报错。java.lang.NoClassDefFoundError
标签:lang,java,NoClassDefFoundError,jar,maven,清单 From: https://www.cnblogs.com/juanxincai/p/18428560