1.运行Spring Cloud Gateway报错
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'routeDefinitionRouteLocator' defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]: Unsatisfied dependency expressed through method 'routeDefinitionRouteLocator' parameter 4; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.core.convert.ConversionService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=webFluxConversionService)}
问题原因:Spring mvc和Spring Cloud Gateway不兼容
检查一下,发现存在依赖
<!-- <dependency>--> <!-- <groupId>org.springframework</groupId>--> <!-- <artifactId>spring-webmvc</artifactId>--> <!-- </dependency>-->
解决方案:
1.删除该依赖
2.增加自定义 ConversionServiceConfig
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
@Configuration
public class ConversionServiceConfig {
@Bean
public ConversionService webFluxConversionService() {
return new DefaultConversionService();
}
}
637

被折叠的 条评论
为什么被折叠?



