配置spring cloud gateway與spring-boot-starter-web衝突報錯

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.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章