第一步:添加pom依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
第二步:编写application.yml
server:
port: 10000
spring:
application:
name: gateway
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
gateway:
discovery:
locator:
enabled: true
routes:
- id: home-service
uri: lb://home-service
predicates:
- Path=/**
- id: user-service
uri: lb://user-service
predicates:
- Path=/**
第三步:测试http://localhost:10000/home-service/index
关于使用服务网关后出现静态资源加载失败问题
链接:https://blog.csdn.net/weixin_45528987/article/details/105394674