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.