jk24680
jk24680
采纳率50%
2019-01-21 20:55 阅读 635

用gradle构建的springboot项目,为什么在cmd中java -jar命令执行build/libs下的jar包会出错

java javac java-version控制台都正常
jdk版本是1.8
gradle版本是5.1.1
springboot版本是1.5.2

使用gradle build构建完spring boot项目后
再用java -jar命令执行后就出错了
图片说明

D:\Program Files\eclipse2018\eclipse2018workspace\init-start\build\libs>java -jar init-start-0.0.1-SNAPSHOT.jar
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
at com.zhou.spring.boot.blog.initstart.InitStartApplication.main(InitStartApplication.java:10)
... 8 more
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 9 more

            一天了弄不好,是什么原因,其他文件javac编译和java执行都是正常的
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

相关推荐