spring boot应用程序在java 11中启动失败,带有gradle

wa7juj8i  于 2021-07-23  发布在  Java
关注(0)|答案(1)|浏览(483)

我正在将我的SpringBoot应用程序从Java1.8升级到Java11。我使用的是springboot1.5.12.release版本和gradle6.6.1版本。gradle构建是成功的,但是当尝试运行应用程序时,我看到下面的错误。我被这两天的事情缠住了。我们已经将类似的应用程序从Java1.8升级到11,使用与上面相同的SpringBoot版本,但是使用maven。非常感谢您的帮助。我在谷歌尝试了不同的解决方案,但无法解决。

Task :bootRun FAILED
Exception in thread "main" java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
        at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getUrls(DefaultRestartInitializer.java:93)
        at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getInitialUrls(DefaultRestartInitializer.java:56)
        at org.springframework.boot.devtools.restart.Restarter.<init>(Restarter.java:140)
        at org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:583)
        at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationStartingEvent(RestartApplicationListener.java:67)
        at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:45)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
        at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:69)
        at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:292)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
        at com.App.main(App.java:16)

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':bootRun'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
xienkqul

xienkqul1#

SpringBoot1.5与Java11不兼容。它也不再受支持。您可以继续使用Java8并继续使用SpringBoot1.5,也可以升级到SpringBoot2.3.x或2.4.x,它们都支持Java11(除了仍然支持Java8之外)。

相关问题