admin管理员组文章数量:1794759
SpringCloud配置网关时运行项目出现Consider defining a bean of type ‘org.springframework.http.codec.ServerCodecCo
错误详情 Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2020-11-28 09:26:11.105 ERROR 19816 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** 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. 错误分析
网关异常出现Consider defining a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' in your configuration.要排除其他依赖的spring-boot-starter-web以及spring-boot-starter-webflux,因为会与spring-boot-starter-gateway的webflux冲突
错误解决将原本的gateway依赖
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway</artifactId> </dependency>修改为
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </exclusion> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </exclusion> </exclusions> </dependency>刷新pom.xml文件后,再次运行项目 修改前: 修改后: 问题解决
峰回路转按照上面的操作去做,问题确实是解决了,运行也没有问题了,但是网关作用失效了 运行成功的上面,还是提示了 访问网关(网关配置正常) 访问结果,404 博主在此纠结了两天,一直以为是网关配置错误的原因,后面尝试着用了下面的方法,最终解决问题,也发现了前面方法的问题,是网关失效了(与配置文件无关,是环境的问题)
解决方法由于spring-boot-starter-web依赖产生的问题,所以我们找到这个依赖是如何进入我们当前的模块的,只有两种方式:1.从父项目中继承;2.自身添加
版权声明:本文标题:SpringCloud配置网关时运行项目出现Consider defining a bean of type ‘org.springframework.http.codec.ServerCodecCo 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686554456a81261.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论