当前位置:网站首页>Gateway 网关报错 SERVICE_UNAVAILABLE
Gateway 网关报错 SERVICE_UNAVAILABLE
2022-07-25 14:13:00 【林凡尘coding】
背景
在搭建微服务框架的时候使用的Gateway网关,网关通了,但是在调用服务的时候报了异常。
SERVICE_UNAVAILABLE "Unable to find instance for admin-auth"
相关配置
admin-gateway.yml 依赖
<dependencies>
<!-- 原因:该版本SpringCloud不再默认优先加载bootstrap.yml文件,解决办法:添加spring-cloud-starter-bootstrap依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<!-- SpringCloud Gateway -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel Gateway -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
</dependency>
<!-- Sentinel Datasource Nacos -->
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
</dependencies>
配置
server:
port: 10010
spring:
application:
name: @[email protected]
cloud:
nacos:
server-addr: 127.0.0.1:8848 # nacos地址
gateway:
discovery:
locator:
enabled: true
routes:
- id: admin-auth # 路由标识,必须唯一
uri: lb://admin-auth # 路由的目标地址,lb为load balance,负载均衡
predicates: # 路由断言,判断请求是否符合规则
- Path=/admin-auth/** # 判断请求是否以/user开头
解决
因为Gateway底层使用了Ribbon作为负载均衡,依赖中没有加入相关的组件,所以不可以进行正确的分发。加入即可:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
边栏推荐
- 在线问题反馈模块实战(十三):实现多参数分页查询列表
- Xintang nuc980 set DHCP or static IP
- 知名手写笔记软件 招 CTO·坐标深圳
- Pytorch uses tensorboard to realize visual summary
- Common problems in the use of wireless vibrating wire acquisition instrument
- opencv视频跟踪「建议收藏」
- A small part is exposed on one or both sides of the swiper
- MySQL table operation
- CDA level Ⅰ 2021 new version simulation question 2 (with answers)
- Brush questions - Luogu -p1075 prime factor decomposition
猜你喜欢

Advantages of wireless relay acquisition instrument and wireless network for engineering monitoring

Idea settings ignore file configuration when submitting SVN

It is predicted that 2021 will accelerate the achievement of super automation beyond RPA

Comprehensive sorting and summary of maskrcnn code structure process of target detection and segmentation

Okaleido ecological core equity Oka, all in fusion mining mode

2271. 毯子覆盖的最多白色砖块数 ●●

Use of Bluetooth function of vs wireless vibrating wire acquisition instrument

如何设计一个高并发系统?

sqli-labs Basic Challenges Less1-10

Arduino code of key state machine for realizing single, double click, long press and other functions with esp32 timed interrupt
随机推荐
苹果手机端同步不成功,退出登录,结果再也登录不了了
PHP website design ideas
Realize a family security and environmental monitoring system (II)
[原创]九点标定工具之机械手头部相机标定
Goldfish rhca memoirs: cl210 management storage -- object storage
Brush questions - Luogu -p1047 trees outside the school gate
AI model risk assessment Part 1: motivation
Engineering monitoring multi-channel vibrating wire sensor wireless acquisition instrument external digital sensor process
Comprehensive sorting and summary of maskrcnn code structure process of target detection and segmentation
dp-851
金鱼哥RHCA回忆录:CL210管理存储--管理共享文件系统
Idea regular expression replacement (idea regular search)
实现一个家庭安防与环境监测系统(二)
Application engineering safety monitoring of wireless vibrating wire acquisition instrument
sqli-labs Basic Challenges Less11-22
Mysql表的操作
Leetcode 205. isomorphic string (2022.07.24)
sqli-labs Basic Challenges Less1-10
Pytorch uses tensorboard to realize visual summary
CTS test introduction (how to introduce interface test in interview)