关键日志如下:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'javax.servlet.Filter' available:
expected at least 1 bean which qualifies as autowire candidate.
Dependency annotations:{@org.springframework.beans.factory.annotation.Qualifier(value=httpTraceFilter)}
原因:该启动异常是由于Spring Boot和Spring Cloud版本不相对应导致。需要特别注意的使用Spring Boot和Spring Cloud进行开发时要求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
而我在使用的Spring Boot和Spring Cloud的版本信息如下:
<spring.boot.version>2.2.2.RELEASE</spring.boot.version>
<spring.cloud.version>Greenwich.SR6</spring.cloud.version>
依赖如下:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring.cloud.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
通过上述说明后,相信都知道如下修改,所以修改后的版本信息如下(选择2.1.x 的某个版本):
<spring.boot.version>2.1.13.RELEASE</spring.boot.version>
<spring.cloud.version>Greenwich.SR6</spring.cloud.version>