为了说明问题特意将错误演示。
错误如下:
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)Vat org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:157)
是由于spring boot与spring cloud版本兼容性导致的,在pom.xml中修改配置文件,修改前:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
再次启动项目,成功。
给出大家一个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的关系匹配,就不会出现该报错了。