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.