12

应用程序无法启动


描述:

modifyRequestBodyGatewayFilterFactory方法中的参数 0需要找不到org.springframework.cloud.gateway.config.GatewayAutoConfiguration类型的 bean 。'org.springframework.http.codec.ServerCodecConfigurer'

行动:

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

拾取 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

4

5 回答 5

21

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

@Bean
public ServerCodecConfigurer serverCodecConfigurer() {
   return ServerCodecConfigurer.create();
}
于 2020-01-10T04:17:52.157 回答
4

你可以这样尝试:

  compile ('org.springframework.cloud:spring-cloud-starter-gateway'){
        exclude module : 'spring-cloud-starter'
        exclude module : 'spring-boot-starter-webflux'
    }
于 2019-07-17T06:52:29.247 回答
3

我在构建 Spring Cloud 版本时遇到了同样的问题2020.0.0Keycloak似乎jar 文件包含对 Telling maven NOT to include defaultKeycloak的依赖,如下解决了该问题。spring-boot-start-webspring-boot-start-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>

但是我必须在servletjar 中包含一个 maven 依赖项,以解决以下一些其他要求Keycloak

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>4.0.1</version>
 </dependency>
于 2021-04-10T16:26:06.740 回答
1

同样的问题,但解决方案

@Bean
public ServerCodecConfigurer serverCodecConfigurer() {
   return ServerCodecConfigurer.create();
}

只隐藏问题,让应用程序编译。无论如何,它使我的网关无法正常工作。yaml如果我在url中定义请求,它不会转发、记录和响应任何内容。应用程序刚刚开始,就是这样。

在我的情况下,问题是spring-boot-start-web依赖。偶然我没有发现它,因为在我的项目结构中,我build.gradle由“父”继承,而该父spring-boot-start-web在子项目中实现。

我删除了这种依赖关系,因为我的请求被正确转发并且我看到了日志。比我删除@BeanServerCodecConfigurer .

希望它可以帮助处于相同情况的任何人。

配置:Spring Boot:2.4.4
Spring Cloud:2020.0.2

于 2021-05-05T12:06:34.793 回答
0

对我来说,问题是我添加了依赖项:

<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-core</artifactId>
    <version>10.1.0-M4</version>
</dependency>

如果您使用的是 Reactive Spring,请注意。我需要HttpServletRequest这种依赖,但现在我正在使用ServerHttpRequestfrom org.springframework.http.server.reactive

于 2021-09-08T10:17:44.757 回答