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

今天在使用idea搭建spring cloud的时候,报以下错误:

java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.([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:74)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:351)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:317)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
    at com.waterlufei.ServiceAApplication.main(ServiceAApplication.java:12)

Process finished with exit code 1

是由于spring boot版本兼容性导致的,在pom.xml中修改配置文件,修改前:

<parent>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-parentartifactId>
    <version>2.0.0.RELEASEversion>
    <relativePath/> 
parent>

再次启动项目,成功。 

spring boot 2.0.0由于版本不匹配导致的NoSuchMethodError问题解析_第1张图片


给出大家一个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的关系匹配,就不会出现该报错了。


你可能感兴趣的:(SpringCloud)