在Java 11和gradle中启动失败



我正在将我的春季启动应用程序从java 1.8升级到java 11。我使用的是1.5.12的弹簧靴。RELEASE版本和gradle 6.6.1版本。Gradle构建是成功的,但当尝试运行应用程序时,我看到下面的错误。我被这两天的事困住了。我们已经将类似的应用程序从java 1.8升级到11,使用与上面相同的spring启动版本,但使用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

Spring Boot 1.5与Java 11不兼容。它也不再被支持。您可以继续使用Java 8并继续使用Spring Boot 1.5,也可以升级到Spring Boot 2.3。X或2.4。(除了仍然支持Java 8之外)。

相关内容

  • 没有找到相关文章

最新更新