zoukankan      html  css  js  c++  java
  • SpringCloud版本问题

    兴致勃勃地跟随文档创建并配置Eureka Server工程后,启动准备测试,发现报了java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder导致启动失败,下面就来分析下原因:

    一、问题:

    SpringBoot工程在配置Eureka Server后启动报错:

    12:37:49.426 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
    java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:157)
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:98)
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:64)
        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:127)
        at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)
        at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
        at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
        at com.zrk.eurekaserver.EurekaServerApplication.main(EurekaServerApplication.java:12)

    二、原因

    原因是SpringCloud与SpringBoot版本兼容问题

    <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.1.3.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.zrk</groupId>
        <artifactId>eureka-server</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>eureka-server</name>
        <description>Eureka Server</description>
    
        <properties>
            <java.version>1.8</java.version>
        </properties>
    
        <!-- 使用dependencyManagement进行版本管理 -->
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-dependencies</artifactId>
                    <version>Dalston.SR5</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
    
        </dependencyManagement>

    用的SpringCloud版本为Dalston.SR5,SpringBoot版本为2.1.3.RELEASE,而参考官方文档SpringCloud发布版本对应的SpringBoot兼容版本如下:

    Table 1. Release train Spring Boot compatibility
    Release TrainBoot Version

    Greenwich

    2.1.x

    Finchley

    2.0.x

    Edgware

    1.5.x

    Dalston

    1.5.x

    三、解决

    将SpringBoot版本调整为1.5.6.RELEASE再启动就没有问题了

    四、相关参考

    SpringCloud官方文档:https://spring.io/projects/spring-cloud

    SpringCloud版本:https://blog.csdn.net/i_hanjt/article/details/81947366

  • 相关阅读:
    CORS enabled image (Miscellaneous) – HTML 中文开发手册
    PHP fread() 函数
    iswcntrl (Strings) – C 中文开发手册
    HTML DOM createComment() 方法
    HTML draggable 事件属性
    HTML table border 属性
    dedecms开启多站点
    SVN中trunk,branches,tags用法详解
    docker:搭建lamp应用
    centos安装samba
  • 原文地址:https://www.cnblogs.com/zrk3/p/10405989.html
Copyright © 2011-2022 走看看