旧版本的 Spring Boot 无法在 Java 11 上启动 [英] Older versions of spring boot fails to start on Java 11

查看:24
本文介绍了旧版本的 Spring Boot 无法在 Java 11 上启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 spring-boot 应用程序的 1.4.1.RELEASE.Java 8 一切正常.但是,当我将 Java 版本更新到 11 时,我无法使用命令 mvn clean spring-boot:run 运行应用程序.同时我可以打包成功(使用mvn包).当我将 java 版本设置为 8 时,它又可以正常工作了.

[main] ERROR o.s.boot.SpringApplication - 应用程序启动失败java.lang.IllegalStateException: Restarter 尚未初始化在 org.springframework.util.Assert.state(Assert.java:392)在 org.springframework.boot.devtools.restart.Restarter.getInstance(Restarter.java:545)在 org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:48)在 org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)在 org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)在 org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:121)在 org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:85)在 org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:66)在 org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:367)在 org.springframework.boot.SpringApplication.run(SpringApplication.java:313)在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)在 com.myapp.Application.main(Application.java:24)

我可以理解,较新版本的 Spring 可能需要较新版本的 Java.但是不清楚为什么旧的 spring-boot 不能在新的 java 版本上运行.

解决方案

默认情况下,Spring Boot 1.4.1.RELEASE 需要 Java 7 直到 Java 8 强烈推荐,Spring Framework 4.3.3.RELEASE 或更高版本.如果您想在某些版本的 Spring Boot 中使用 Java 11,建议使用最新版本,那么您应该升级您的项目.

<块引用>

尽管您可以将 Spring Boot 与 Java 67 结合使用,但我们通常建议尽可能使用 Java 8.

Spring Boot 1.4.1 的系统要求

开始使用 Java 11 的 Spring Boot 版本是 2.1.1 然后你可以使用任何这个版本.

<块引用>

Spring Boot 2.1.1.RELEASE 需要 Java 8 并且最高兼容 Java 11(包括在内).

Spring Boot 2.1.1 的系统要求

I'm using 1.4.1.RELEASE of spring-boot application. Everything was working ok for Java 8. However when I updated java version to 11 I can't run application using command mvn clean spring-boot:run. At the same time I can package is successfully (using mvn package). When I set java version to 8, it's working fine again.

[main] ERROR o.s.boot.SpringApplication - Application startup failed
    java.lang.IllegalStateException: Restarter has not been initialized
        at org.springframework.util.Assert.state(Assert.java:392)
        at org.springframework.boot.devtools.restart.Restarter.getInstance(Restarter.java:545)
        at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:48)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:121)
        at org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:85)
        at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:66)
        at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:367)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
        at com.myapp.Application.main(Application.java:24)

I can understand that newer versions of Spring might require newer version of Java. But it's not clear why older spring-boot can't be run on newer java versions.

解决方案

By default, Spring Boot 1.4.1.RELEASE requires Java 7 until Java 8 which is highly recommended and Spring Framework 4.3.3.RELEASE or above. If you want to use Java 11 with some version of Spring Boot, The latest version is recommended to use, then you should do a upgrade your project.

Although you can use Spring Boot with Java 6 or 7, we generally recommend Java 8 if at all possible.

System Requirements for Spring Boot 1.4.1

The version of Spring Boot which starts to use Java 11 it was 2.1.1 then you can use any up to this version.

Spring Boot 2.1.1.RELEASE requires Java 8 and is compatible up to Java 11 (included).

System Requirements for Spring Boot 2.1.1

这篇关于旧版本的 Spring Boot 无法在 Java 11 上启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆