springboot项目启动的时候,运行main方法报错NoClassDefFoundError问题
作者:_晓夏_
springboot项目启动运行main方法报错NoClassDefFoundError
spring boot项目启动的时候 ,运行main方法报错如下:NoClassDefFoundError
Connected to the target VM, address: '127.0.0.1:58203', transport: 'socket'
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
at com.xxx.IndstApp.main(IndstApp.java:17)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more
Disconnected from the target VM, address: '127.0.0.1:58203', transport: 'socket'Process finished with exit code 1
项目代码编译没错,运行的时候报错 NoClassDefFoundError ,这是什么鬼!!
先说解决方案
找到Edit Configurations
Application选项,Shorten command line
切换一下
Application选项,Shorten command line
切换一下,改成 JAR mainifest, 然后重新rebuild 项目, 运行成功!!
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。