报错
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method modifyResponseBodyGatewayFilterFactory
in org.springframework.cloud.gateway.config.GatewayAutoConfiguration
required a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' in your configuration.
分析
查看上面的描述信息,得到关键信息 ServerCodecConfigurer' that could not be found
因为spring cloud gateway
是基于webflux
的,如果非要web支持的话需要导入spring-boot-starter-webflux
而不是spring-boot-start-web
,两者会冲突。
查看GatewayAutoConfiguration
源码
/**
* @author Spencer Gibb
* @author Ziemowit Stolarczyk
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(name = "spring.cloud.gateway.enabled", matchIfMissing = true)
@EnableConfigurationProperties