springBoot項目與Eureka註冊中心整合時候關於版本兼容問題

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

若是在搭建springboot項目的時候遇到過這樣的問題,那麼這個問題就是版本兼容問題。
還有一種狀況就是關於綁定的問題。提示binder failed,問題大概相似。
這個問題也困擾了我好久。上週五搭建報表項目的時候也忽然又遇到這個問題了,因此週六日回去研究了一番,也參考了一些博客關於這方便的解決方案。最終經過本身的多個嘗試與分析,解決了問題。java

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

這裏引入註冊中心jar包時是不須要指定版本號的。由於springboot與eureka整合的時候兩個jar的版本很難兼容。因此咱們要讓系統本身去匹配。那麼系統如何自動去自適應呢。spring

<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。啓動項目正常!springboot

拓展

那麼具體問題是什麼呢markdown

spirngcloud版本演變過程

版本名稱 版本
Finchley snapshot版
Edgware snapshot版
Dalston SR1 當前最新穩定版本
Camden SR7 穩定版本
Brixton SR7 穩定版本
Angel SR6 穩定版本ide

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.xui

因此咱們經過配置FINchley 就能夠正常使用Springboot2.0 若是你springboot版本是1.x
那麼能夠嘗試一下用Brixton試試。atom

若是對您有用,麻煩點個贊,順便加個關注。哈哈!spa

發佈了164 篇原創文章 · 獲贊 236 · 訪問量 28萬+
展開閱讀全文 
相關文章
相關標籤/搜索