常用配置 application.yml配置文件
#eureka客户端配置
eureka:
server:
ip: 127.0.0.1
port: 16000
instance:
prefer-ip-address: true
#每间隔2s,向服务端发送一次心跳,证明自己依然”存活“
lease-renewal-interval-in-seconds: 2
#告诉服务端,如果我4s之内没有给你发心跳,就代表我“死”了,将我踢出掉
lease-expiration-duration-in-seconds: 4
client:
register-with-eureka: true
fetch-registry: true
serviceUrl:
defaultZone: http://${eureka.server.ip}:${eureka.server.port}/eureka/
#http请求客户端负载均衡各项配置
feign:
#开启客户端熔断机制
hystrix:
enabled: true
#开启请求和响应的压缩机制(GZIP)
compression:
request:
enabled: true
response:
enabled: true
#zuul转发规则配置
zuul:
#关闭请求转发重试机制(全局关闭)
retryable: false
#添加默认前缀
prefix: /api
#不移除前缀
strip-prefix: true
#重新定义敏感请求头信息,放行全部的请求头部信息
sensitive-headers:
#解决重定向跳转路径问题(这个配置没什么卵用)
add-host-header: true
#配置路由git
routes:
ws_auth:
path: /ws_auth/**
serviceId: ws-auth
strip-prefix: true
#ribbon的全局配置项
ribbon:
#http请求连接建立超时时间(ms)
ConnectTimeout: 5000
#http请求处理超时时间(ms)
ReadTimeout: 15000
#默认重试次数
MaxAutoRetries: 1
#默认尝试的实例数
MaxAutoRetriesNextServer: 2
#熔断机制配置
#熔断的超时时间(ms)
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 15000
#线程隔离策略配置,官方推荐使用THREAD,即下游依赖的请求在一个单独的线程中隔离,这里为了解决feign转发时需要携带head信息所以讲策略设置为SEMAPHORE,即下游依赖请求在当前调用线程中执行
strategy: SEMAPHORE
在这里插入代码片