Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bean of type 'org.springframework.http.codec.ServerCodecConfigurer' that could not be found

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.

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

like image 768
Dheeraj Reddy Avatar asked Sep 21 '18 15:09

Dheeraj Reddy


3 Answers

Try adding the below code. It worked for me

@Bean
public ServerCodecConfigurer serverCodecConfigurer() {
   return ServerCodecConfigurer.create();
}
like image 159
ITIB Avatar answered Nov 15 '22 15:11

ITIB


You can try like this:

  compile ('org.springframework.cloud:spring-cloud-starter-gateway'){
        exclude module : 'spring-cloud-starter'
        exclude module : 'spring-boot-starter-webflux'
    }
like image 5
user8653727 Avatar answered Nov 15 '22 13:11

user8653727


I had the same issue building a spring cloud version 2020.0.0 and Keycloak, it seems that the Keycloak jar files includes a dependency on spring-boot-start-web Telling maven NOT to include the default spring-boot-start-web as follows resolved that issue.

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

But I had to include a maven dependency to the servlet jar as to resolve some other requirements of Keycloak as follows:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>4.0.1</version>
 </dependency>
like image 3
Dave Avatar answered Nov 15 '22 15:11

Dave