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 项目, 运行成功!!