spring-cloud / spring-cloud-gateway

An API Gateway built on Spring Framework and Spring Boot providing routing and more.
http://cloud.spring.io
Apache License 2.0
4.52k stars 3.32k forks source link

GatewayAutoConfiguration required a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' that could not be found. #2326

Closed KyrieY closed 3 years ago

KyrieY commented 3 years ago

bug description:

Parameter 0 of method modifyRequestBodyGatewayFilterFactory 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.

============================================================================ dependencies:

org.springframework.boot spring-boot-starter-parent 2.2.7.RELEASE Hoxton.SR4 org.springframework.cloud spring-cloud-starter-gateway com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery
spencergibb commented 3 years ago

this happens when spring-boot-starter-web is on the classpath and this has been fixed #2176

mmm8955405 commented 2 years ago

Spring boot 2.7.3 encountered the same problem. Spring boot starter web is not under the classpath

jongsun112 commented 1 year ago

any solutions?

1250529731 commented 8 months ago

any solutions?

abaranya commented 8 months ago

Still happening. Any workaround?

qyx-git commented 2 months ago

Remove the spring boot start web dependency. Because the Spring Cloud Gateway is based on WebFlux, if web support is required, it is necessary to import Spring Boot Starter WebFlux instead of Spring Boot Start Web. Then we can simply remove the jar dependency on the spring boot start web module in pom.xml.