Spring Cloud Gateway服务器未使用Spring Cloud 2023.0.0启动

sq1bmfud  于 12个月前  发布在  Spring
关注(0)|答案(3)|浏览(165)

我正在尝试创建Spring Cloud Gateway服务器。但当服务器启动时出现以下错误

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

字符串

Sping 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

mzmfm0qo

mzmfm0qo1#

这似乎是一个类修饰符错误给我。去下面的类,并检查它是否是final或不是。如果你已经声明了它final然后删除final关键字作为Spring编译过程要求类是非final的。它也需要可见。

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

字符串

eqqqjvef

eqqqjvef2#

尝试将POM中的依赖项从“gateway-mvc”更改为“gateway”;

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

字符串
下面;

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

4dbbbstv

4dbbbstv3#

似乎spring-cloud-starter-gateway-mvcspring-boot-devtools冲突
试着删除spring-boot-devtools,希望能有帮助

相关问题