原因
maven依賴的錯
我在兩個不同的地方分別引用了spring-boot-starter-parent
一個地方是2.2.4.RELEASE
另一個是2.1.8.RELEASE
修改方法
版本保持一直就行,我改成了最新的版本
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
</parent>
其他辦法
使用 Hoxton.RELEASE 版本可以解決這個問題
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
這裏需要注意一個坑就是Spring Boot 的版本要和 Spring Cloud 的版本相對應,如果版本不對應,會遇到很多報錯的情況,他們的匹配關係是:
Spring Cloud Hoxton --> Spring Boot 2.2.x
Spring Cloud Greenwich --> Spring Boot 2.1.x
Spring Cloud Finchley --> Spring Boot 2.0.x
Spring Cloud Edgware --> Spring Boot 1.5.x
參考
1. 記錄一次springboot結合eureka的坑 “No qualifying bean of type ‘javax.servlet.Filter’ available”
2. SpringCloud 啓動"No qualifying bean of type ‘javax.servlet.Filter’ available"問題
3. 啓動springcloud eureka報錯