Tushar Girase
Tushar Girase

Reputation: 363

Spring Cloud Gateway server not starting up with Spring Cloud 2023.0.0

I am trying to create Spring Cloud Gateway server. But when server is getting started getting below error

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'routerFunctionMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Error creating bean with name 'gatewayCompositeRouterFunction': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'gatewayRouterFunctionHolder' defined in BeanDefinition defined in null: Could not generate CGLIB subclass of class org.springframework.cloud.gateway.server.mvc.config.GatewayMvcPropertiesBeanDefinitionRegistrar$RouterFunctionHolder: Common causes of this problem include using a final class or a non-visible class

Spring boot version 3.2.0 spring-cloud.version 2023.0.0 java.version 17

application.properties

spring.application.name=gateway-server
server.port=9090


# Eureka config
eureka.client.service-url.defaultZone=${EUREKA_URI:http://localhost:8761/eureka}

spring.cloud.gateway.discovery.locator.lower-case-service-id=true

spring.cloud.gateway.discovery.locator.enabled=true

Upvotes: 5

Views: 3058

Answers (5)

Swamy
Swamy

Reputation: 1

Just Remove "spring-boot-devtools" and Re-Start the Application.,i hope it works fine

Upvotes: 0

Sagar Shrivastava
Sagar Shrivastava

Reputation: 1

In the latest releases, spring has changed the artifact id from spring-cloud-starter-gateway-mvc to spring-cloud-starter-gateway.

<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>

Upvotes: 0

Edwin
Edwin

Reputation: 51

It seems that spring-cloud-starter-gateway-mvc conflicts with spring-boot-devtools

Just try remove spring-boot-devtools, hope it could help

Upvotes: 5

ThivankaW
ThivankaW

Reputation: 540

Try changing dependency in your POM from 'gateway-mvc' to 'gateway';

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway-mvc</artifactId>
</dependency>

to below;

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>

Upvotes: 1

Syed Sheheryar Umair
Syed Sheheryar Umair

Reputation: 109

It seems to be a class modifier error to me. Go to the below class and check whether it is final or not. If you have declared it final then remove the final keyword as Spring proxying process requires the class to be not-final. It needs to be visible too.

org.springframework.cloud.gateway.server.mvc.config.GatewayMvcPropertiesBeanDefinitionRegistrar$RouterFunctionHolder

Upvotes: 0

Related Questions