无法找到“org.springframework.http.codec.ServerCodecConfigurer”类型的bean

Dhe*_*ddy 11 java spring javabeans spring-boot spring-framework-beans

应用程序无法启动


描述:

方法的参数0modifyRequestBodyGatewayFilterFactoryorg.springframework.cloud.gateway.config.GatewayAutoConfiguration类型需要一个bean 'org.springframework.http.codec.ServerCodecConfigurer',可能不会被发现。

行动:

考虑'org.springframework.http.codec.ServerCodecConfigurer'在您的配置中定义一个类型的 bean 。

选择了 JAVA_TOOL_OPTIONS:-agentlib:jvmhook
选择了 _JAVA_OPTIONS:-Xbootclasspath/a:"C:\Program Files (x86)\HPE\Unified Functional Testing\bin\java_shared\classes\jasmine.jar"
选择了 JAVA_TOOL_OPTIONS: -agentlib: jvmhook

ITI*_*TIB 19

尝试添加以下代码。它对我有用

@Bean
public ServerCodecConfigurer serverCodecConfigurer() {
   return ServerCodecConfigurer.create();
}
Run Code Online (Sandbox Code Playgroud)

  • 这对我有用,但只能配置网关内的基本安全性。我稍后仍需要将 `spring-boot-start-web` 替换为 `spring-boot-start-webflux`。对于任何感兴趣的人,[Spring 博客](https://spring.io/blog/2019/08/16/securing-services-with-spring-cloud-gateway) 有一个很好的代码示例 (2认同)

小智 6

你可以这样尝试:

  compile ('org.springframework.cloud:spring-cloud-starter-gateway'){
        exclude module : 'spring-cloud-starter'
        exclude module : 'spring-boot-starter-webflux'
    }
Run Code Online (Sandbox Code Playgroud)