搭建spring cloud gateway 服务

本文详细介绍了Spring Cloud Gateway的配置方法,包括应用名称、环境配置、Thymeleaf模式设置、Jackson日期格式化等。此外,还展示了如何配置路由、负载均衡及安全设置等关键信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

先提供一个官方文档地址:https://cloud.spring.io/spring-cloud-gateway/reference/html/

漏掉一个

org.springframework.cloud spring-cloud-starter-netflix-hystrix

application.yml

spring:
application:
name: lrkj-gateway
profiles:
active: dev

application-dev.yml

spring:
application:
name: lrkj-gateway
thymeleaf:
mode: LEGACYHTML5
cache: false
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
default-property-inclusion: non_null
security:
basic:
enabled: true
redis:
host: 192.168.1.63
password:
port: 6379
timeout: 3000
database: 10
cloud:
gateway:
routes:
- id: busine
uri: lb://lrkj-busine
predicates:
- Path=/busine/**
- id: userInfo
uri: lb://lrkj-user
predicates:
- Path=/userInfo/**
loadbalancer:
ribbon:
enabled: false

server:
port: 8610

#zuul:

sensitive-headers:

host:

maxTotalConnections: 100000

maxPerRouteConnections: 10000

semaphore:

maxSemaphores: 15000

routes:

busine:

path: /busine/**

serviceId: xxcy-busine

user:

path: /userInfo/**

serviceId: xxcy-user

#ribbon:

eureka:

enabled: true

ReadTimeout: 6000 #请求处理的超时时间

ConnectTimeout: 2000 #请求连接的超时时间

MaxAutoRetries: 1 #对当前实例的重试次数

MaxAutoRetriesNextServer: 1 #切换实例的重试次数

OkToRetryOnAllOperations: false #对所有操作请求都进行重试

#hystrix:

threadpool:

default:

coreSize: 1000 ##并发执行的最大线程数,默认10

maxQueueSize: 1000 ##BlockingQueue的最大队列数

queueSizeRejectionThreshold: 500 ##即使maxQueueSize没有达到,达到queueSizeRejectionThreshold该值后,请求也会被拒绝

command:

default:

execution:

isolation:

thread:

timeoutInMilliseconds: 33000

eureka:
instance:
statusPageUrlPath: /info
healthCheckUrlPath: /health
prefer-ip-address: true
instance-id: s p r i n g . c l o u d . c l i e n t . i p − a d d r e s s : {spring.cloud.client.ip-address}: spring.cloud.client.ipaddress:{server.port}
# docker 部署开启

prefer-ip-address: true

ip-address: 127.0.0.1

client:
serviceUrl:
defaultZone: http://localhost:8600/eureka

logging:
level:
root: WARN

feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
loggerLevel: basic

system:
ip: 192.168.1.63

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值