配置spring cloud gateway与spring-boot-starter-web冲突报错

2023-04-07 12:49:38
The following candidates were found but could not be injected:
	- Bean method 'routeLocatorBuilder' in 'GatewayAutoConfiguration' not loaded because @ConditionalOnClass did not find required class 'org.springframework.web.reactive.DispatcherHandler'


Action:

Consider revisiting the entries above or defining a bean of type 'org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder' in your configuration.

配置gateway 很多时候会出现以上的错误,这个是同时引入了以下的依赖包导致,
spring-cloud-starter-gateway

spring-boot-starter-web
spring-boot-starter-webflux
gateway和web依赖包不能同时引入。

但需要用到hystrix方法的时候需要引入spring-cloud-starter-netflix-hystrix依赖包

.route("hystrix_fallback_route", r -> r.host("*.hystrixfallback.org")
							.filters(f -> f.hystrix(c -> c.setName("slowcmd").setFallbackUri("forward:/hystrixfallback")))
							.uri("http://httpbin.org"))

否则会报错

Consider revisiting the entries above or defining a bean of type 'org.springframework.cloud.gateway.filter.factory.HystrixGatewayFilterFactory' in your configuration.
  • 作者:奔跑的蜗牛kei
  • 原文链接:https://blog.csdn.net/weixin_46021767/article/details/105174812
    更新时间:2023-04-07 12:49:38