springboot集成springCloud中gateway时启动报错

港控/mmm° 2021-05-13 15:43 1031阅读 0赞

在项目中引入springcloud中的gateway时报以下错误

  1. Description:
  2. Parameter 0 of method modifyRequestBodyGatewayFilterFactory in org.springframework.cloud.gateway.config.GatewayAutoConfiguration
  3. required a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' that could not be found.
  4. Action:
  5. Consider defining a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' in your configuration.

这个是由于依赖冲突,spring-cloud-starter-gateway与spring-boot-starter-web和spring-boot-starter-webflux依赖冲突

解决方式:在引入gateway时过滤掉上面两个依赖

  1. <dependency>
  2. <groupId>org.springframework.cloud</groupId>
  3. <artifactId>spring-cloud-starter-gateway</artifactId>
  4. <exclusions>
  5. <exclusion>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-web</artifactId>
  8. </exclusion>
  9. <exclusion>
  10. <groupId>org.springframework.boot</groupId>
  11. <artifactId>spring-boot-starter-webflux</artifactId>
  12. </exclusion>
  13. </exclusions>
  14. </dependency>

发表评论

表情:
评论列表 (有 0 条评论,1031人围观)

还没有评论,来说两句吧...

相关阅读