spring-cloud-netflix-eureka-client整合springboot启动报错

java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.([Ljava/lang/Object;)V

如果在搭建springboot项目的时候遇到过这样的问题,那么这个问题就是版本兼容问题。
还有一种情况就是关于绑定的问题。提示binder failed,问题大概类似。
这个问题也困扰了我很久。上周五搭建报表项目的时候也突然又遇到这个问题了,所以周六日回去研究了一番,也参考了一些博客关于这方便的解决方案。最终通过自己的多个尝试与分析,解决了问题。

 <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-netflix-eureka-client</artifactId>
        </dependency>

这里引入注册中心jar包时是不需要指定版本号的。因为springboot与eureka整合的时候两个jar的版本很难兼容。所以我们要让系统自己去匹配。那么系统如何自动去自适应呢。

   <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Finchley.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
  • 加入上边的内容系统就可以自动进行匹配了。

我用的springboot 2.1.5.RELEASE,删除本地仓库.重新install 后发现仓库中用的是2.0.0。启动项目正常!

拓展

那么具体问题是什么呢

spirngcloud版本演变过程

版本名称 版本
Finchley snapshot版
Edgware snapshot版
Dalston SR1 当前最新稳定版本
Camden SR7 稳定版本
Brixton SR7 稳定版本
Angel SR6 稳定版本

springboot与springCloud版本匹配关系

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

所以我们通过配置FINchley 就可以正常使用Springboot2.0 如果你springboot版本是1.x
那么可以尝试一下用Brixton试试。

扫描二维码关注公众号,回复: 12995361 查看本文章

猜你喜欢

转载自blog.csdn.net/qq_39809613/article/details/108875632