1、排除依赖
spring-boot-starter-webflux
2、添加依赖
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency>
3、yml进行配置
spring:
cloud:
nacos:
server-addr: 127.0.0.1:8848
gateway:
discovery:
locator:
enabled: true
routes:
- id: aliyunOS
uri: lb://aliyunOS
predicates:
- Path=/aliyun/**
- id: service-cms
uri: lb://service-cms
predicates:
- Path=/cms/**
- id: service-edu
uri: lb://service-edu
predicates:
- Path=/edu/**
- id: service-msm
uri: lb://service-msm
predicates:
- Path=/msm/**
- id: service-order
uri: lb://service-order
predicates:
- Path=/order/**
- id: service-sta
uri: lb://service-sta
predicates:
- Path=/sta/**
- id: service-ucenter
uri: lb://service-ucenter
predicates:
- Path=/ucenter/**
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/guliedu?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
username: root
type: com.alibaba.druid.pool.DruidDataSource
password: msir1234
jackson:
date-format: yyyy-MM-dd HH:mm:ss
application:
name: gateway
redis:
database: 0
host: 43.140.244.236
port: 6379
password:
jedis:
pool:
#最大连接数
max-active: 8
#最大阻塞等待时间(负数表示没限制)
max-wait: -1
#最大空闲
max-idle: 8
#最小空闲
min-idle: 0
#连接超时时间
timeout: 10000
cache:
redis:
time-to-live: 36000
server:
port: 9000
mybatis-plus:
global-config:
db-config:
logic-delete-field: deleted
logic-delete-value: 1
logic-not-delete-value: 0
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#logging:
# level:
#feign:
# hystrix:
# enabled: true
# httpclient:
# connection-timeout: 3000
#feign:
# hystrix:
# enabled: true
# httpclient:
# connection-timeout: 200000
## root: INFO
4、启动类添加
@EnableDiscoveryClient
5、测试