Java 类型为'的bean;org.springframework.http.codec.ServerCodeConfigurer';那是找不到的
应用程序无法启动Java 类型为'的bean;org.springframework.http.codec.ServerCodeConfigurer';那是找不到的,java,spring,spring-boot,javabeans,spring-framework-beans,Java,Spring,Spring Boot,Javabeans,Spring Framework Beans,应用程序无法启动 说明: org.springframework.cloud.gateway.config.GatewayAutoConfiguration中方法modifyRequestBodyGatewayFilterFactory的参数0需要一个类型为'org.springframework.http.codec.ServerCodeConfigurer'的bean,但找不到该bean 行动: 考虑在您的配置中定义类型为“org.springframework.http.codec.se
说明:
org.springframework.cloud.gateway.config.GatewayAutoConfiguration
中方法modifyRequestBodyGatewayFilterFactory
的参数0需要一个类型为'org.springframework.http.codec.ServerCodeConfigurer'
的bean,但找不到该bean
行动:
考虑在您的配置中定义类型为“org.springframework.http.codec.servercodeconfigurer”的bean
选择JAVA工具选项:-agentlib:jvmhook拾取的\u JAVA\u选项:-Xbootclasspath/a:“C:\Program Files(x86)\HPE\Unified Functional Testing\bin\JAVA\u shared\classes\jasmine.jar”
选择JAVA_工具选项:-agentlib:jvmhook您可以这样尝试:
compile ('org.springframework.cloud:spring-cloud-starter-gateway'){
exclude module : 'spring-cloud-starter'
exclude module : 'spring-boot-starter-webflux'
}
尝试添加以下代码。它对我有用
@Bean
public ServerCodecConfigurer serverCodecConfigurer() {
return ServerCodecConfigurer.create();
}
我在构建spring云版本
2020.0.0
和keydove
时遇到了同样的问题,似乎keydove
jar文件包含对spring boot start web
告诉maven不要包含默认的spring启动web
,如下解决了这个问题
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
</exclusions>
</dependency>
这里也有同样的问题,但解决方法是
@Bean
public ServerCodecConfigurer serverCodecConfigurer() {
return ServerCodecConfigurer.create();
}
只隐藏问题,让应用程序编译。无论如何,它使我的网关无法正常工作。如果我使用yaml
url中定义的请求,它不会转发、记录和响应任何内容。应用程序刚刚启动,就这样
在我的例子中,问题是springbootstartweb
依赖性。我无意中发现了它,因为在我的项目结构中,我的build.gradle
是由“父”继承的,而该父在子项目中实现了spring boot start web
我删除了那个依赖项,因为我的请求被正确地转发了,我看到了日志。然后我用servercodeconfigurer
删除了@Bean
希望它能帮助任何处于同样情况的人
配置:
弹簧靴:2.4.4SpringCloud:2020.0.2这可能是因为您通过SpringCloudGateway包含SpringBootStartWebjar,而使用SpringBootStarterWebFlux。所以,删除spring boot start web可能会解决这个问题。您可以共享您的pom或gradle文件吗?这对我来说很有效,但仅用于在网关内配置基本安全性。后来我仍然需要用
springbootstartwebflux
替换springbootstartwebflux
。对于任何感兴趣的人来说,这里有一个很好的代码示例。我应该在哪里添加上面的代码?答案是指gradle构建系统,您可以对名为build.gradle的文件进行更改。如果您使用mavin,则必须更改pom.xml和use语句。
@Bean
public ServerCodecConfigurer serverCodecConfigurer() {
return ServerCodecConfigurer.create();
}