• spring boot 2.0.0由于版本不匹配导致的NoSuchMethodError问题解析


    spring boot升级到2.0.0以后,项目突然报出 NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init> 异常,

    跟踪源代码无果的情况下。突然想到有可能是spring boot 和 spring cloud版本不匹配导致的。
    于是,上官网看spring cloud的依赖,首先看Edgware.SR2版本的依赖,可以看出Edgware.SR2依赖是1.5.X版本

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.10.RELEASE</version>
    </parent>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Edgware.SR2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    

    再看Finchley版本的依赖,可以看出Finchley依赖的是2.0.0版本

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
    </parent>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Finchley.BUILD-SNAPSHOT</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    

    查看官网目前最新的Finchley版本是Finchley.M8,所以对于使用spring boot2.0.0的朋友,只要将对应的spring cloud切换为Finchley.M8版本,即可解决SpringApplicationBuilder.<init>报出NoSuchMethodError的问题。下面给出大家一个spring boot版本和spring cloud版本的匹配关系:

    Spring Cloud Spring Boot
    Finchley 兼容Spring Boot 2.0.x,不兼容Spring Boot 1.5.x
    Dalston和Edgware 兼容Spring Boot 1.5.x,不兼容Spring Boot 2.0.x
    Camden 兼容Spring Boot 1.4.x,也兼容Spring Boot 1.5.x
    Brixton 兼容Spring Boot 1.3.x,也兼容Spring Boot 1.4.x
    Angel 兼容Spring Boot 1.2.x

    只要按照上述表格做spring boot和spring cloud的关系匹配,就不会出现该报错了。

  • 相关阅读:
    快捷JS PHP
    css userAgent (简易浏览器区分) PHP
    http://fw.qq.com/ipaddress PHP
    JS竖排文字 PHP
    奇怪的body PHP
    使用36进制,无损压缩GUID到26位 PHP
    链接<a>执行JS PHP
    纯JS省市区三级联动 PHP
    Table 样式 PHP
    Exceeded storage allocation. The server response was: 4.3.1 Message size exceeds fixed maximum message size
  • 原文地址:https://www.cnblogs.com/zer0Black/p/8613224.html
Copyright © 2020-2023  润新知