我使用 Spring Cloud Gateway 和微服务开发新项目。当我使用微服务自己的端口运行该方法时,该方法有效。但是当我用网关的端口调用它时,路由操作不会发生。另外,User Service 和 Gateway 注册在 Eureka Server 上,并使用 DiscoveryClient 注解
(类型=未找到,状态=404)。
网关 YAML 文件
server: port: 9191 spring: application: name: API-GATEWAYcloud: gateway: routes: -id: USER-SERVICE uri: lb://USER-SERVICE/ predicates:-Path=/user/**
eureka: client: service-url: defaultZone: http://localhost:8761/eureka/ register-with-eureka: true fetch-registry: true instance: hostname: localhost
我使用 yml 文件进行配置。我将 yml 文件转换为属性文件,问题解决了