首页 > 其他分享 >springcloud gateway根据服务名称进行路由失败There was an unexpected error (type=Service Unavailable, status=503).

springcloud gateway根据服务名称进行路由失败There was an unexpected error (type=Service Unavailable, status=503).

时间:2022-12-24 14:11:34浏览次数:45  
标签:status applicationName unexpected Unavailable application 路由 type gateway cloud

出现错误,如下图:

解决办法:
检查自己的yaml文件:

server:
  port: 88
spring:
  application:
    name: applicationName
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848

    gateway:
#      开启服务发现路由(不开启跨域问题可能无法解决)
      discovery:
        locator:
          enabled: true

      routes:
        - id: applicationName
          uri: lb://applicationName    
          predicates:
            - Path=/keyword/**
  main:
    web-application-type: reactive


如果确定yaml文件是正确的,那就查看自己是否存在loadbalancer依赖,作用是用来负载均衡

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

最后重启gateway就可以解决了。

标签:status,applicationName,unexpected,Unavailable,application,路由,type,gateway,cloud
From: https://www.cnblogs.com/just1t/p/17002830.html

相关文章