spring spring cloud 配置信息

spring.main.banner-mode:是否开启spring boot启动时的banner

spring.output.ansi.enabled:设置支持彩色日志输出


一、服务注册中心配置

spring.profiles.active:选择相应开发环境的配置文件,值为profile,application-{profile}.properties 

spring.application.name:配置应用名

server.port=1001:配置端口号

eureka.instance.hostname:配置主机名

eureka.client.register-with-eureka:禁用eureka客户端的注册行为,在默认设置下,该服务注册中心会将自己作为客户端来尝试注册它自己,所以eureka服务器设置为false,但集群是好像要设置为true

eureka.client.fetch-registry:获取服务,消费者必需设置为true,默认为true

eureka.instance.prefer-ip-address:不使用主机名来定义注册中心的地址,而使用IP地址的形式,该值默认为false,即使用主机名定义地址。

eureka.server.enable-self-preservation:配置是否关闭注册中心的保护机制,默认为true,有利于维护服务实例。

eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/discovery/eureka/   访问http:discovery:8001/discovery就可以了,当然这里要修改hosts文件


 


二、服务注册客户端配置

eureka.client.serviceUrl.defaultZone:指定服务注册中心的位置,可以配置多节点的服务注册中心,将服务注册到

Eureka Server集群中,只需要一英文逗号隔开。

eureka.instance.lease-renewal-interval-in-seconds:配置服务续约任务的调用间隔时间,默认为30秒

eureka.instance.kease-expiration-duration-in-seconds:定义服务失效时间,默认为90秒。

eureka.instance.instanceId:配置实例名

logging.level.org.springframework.web.servlet.DispatcherServlet:配置springmvc请求分发的日志级别

eureka.instance.hostname:配置主机名

eureka.instance.appname:注册到eureka上的服务名,默认为应用名


三、消费者配置

eureka.client.fetch-registry:获取服务,这里必需配置为true

eureka.client.registry-fetch-interval-seconds:定义缓存清单的更新时间,默认为30秒


四、端点配置

eureka.instance.statusPageUrl:/info端点配置,可以配置相对路径也可以配置绝对路径。

eureka.instance.healthCheckUrl:/health端点配置,可以配置相对路径也可以配置绝对路径。

eureka.instance.homePageUrl:主页配置,可以配置相对路径也可以配置绝对路径。

eureka.client.healthcheck.enabled:配置将eureka客户端的健康检测交给actuator模块的/health端点,默认为false


五、ribbon配置

hello-service.ribbon.NFLoadBalancerPingClassName=com.netflix.loadbalancer.PingUrl

将hello-service服务客户端的IPing接口实现替换为PingUrl,形式为<clientName>.ribbon.<key>=<value>

ribbon.ConnectTimeout:Ribbon创建连接的超时时间。

ribbon.readTimeout:Ribbon读超时时间。

ribbon.eureka.enabled=false:禁用Eureka对Ribbon服务实例的维护实现。


六、Feign配置

feign.hystrix.enabled:该参数配置是否开启feign集成的hystrix

feign.compression.request.enabled:是否开启请求压缩功能

feign.compression.respone.enabled:是否开启响应压缩功能

feign.hystrix.enabled=true:启用hystrix服务降级,默认为false好像



七、gateway配置

zuul.routes.api-a.path=/eureka-client/**  :路由配置,配置了要路由的访问路径,api-a为路由的名字,可以任意定义.

zuul.routes.api-a.ur=http://127.0.0.1:2001/  :路由配置,配置api-a路由的转发路径。forward:/local表示本地跳转,请求交给本地/local处理。

zuul.routes.api-a.serviceId=eureka-client :和上面一条作用一样,只不过这里引用服务名,需要引入eureka依赖。

zuul.routes.api-a.eureka-client=/eureka-client/**

简洁配置,将/eureka-client/**的请求转发到eureka-client服务的实例上。这也是zuul的默认配置规则,会把服务名路径下的请求转发到相应服务实例上,可以使用下面参数来忽略

zuul.ignored-services:设置一个服务名匹配表达式来定义不自动创建路由的规则。*表示关闭所有的默认路由。

zuul.ignored-patterns=/**/hello/**:/hello接口不被路由。**匹配多级目录。对左右路由有效。

eureka-client.ribbon.listOfServers=http://localhost:1001/eureka/,http://localhost:1002/eureka/

指定eureka-client服务的实例列表,路由会被转发到列表中的所有实例上。

ribbon.eureka.enabled:配置是否获取配置服务名对应的实例清单。

zuul.routes.<router>.sensitiveHeaders= :路由的敏感头设置为空,开启网关对敏感信息的传递。

zuul.addHostHeader=true:配置路由转发前为请求头设置host信息,解决重定向问题。

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds:设置转发请求的执行超时时间。

zuul.retryable:设置是否开启重试机制,默认开启。这个是全局配置。

zuul.routes.<route>.retryable:关闭指定路由的重试机制。

zuul.<SimpleClassName>.<filterType>.disable:禁用过滤器。

zuul.routes.local.path=/local/**

zuul.routes.local.url=/local        Zuul的本地跳转,所有/lcoal/**的请求交给本地的/local处理


七、配置中心配置

服务端配置:

spring.cloud.config.server.git.uri:配置git远程仓库地址

spring.cloud.config.server.git.username:github帐号

spring.cloud.config.server.git.password:github密码

management.security.enabled:是否开启权限控制

security.user.name:设置security权限的帐号

security.user.password:设置security权限的密码


客户端配置:

spring.cloud.config.name:要获取的配置信息所在的配置文件名

spring.cloud.config.discovery.enabled:设置是否使用服务名指定配置服务端,默认为false
spring.cloud.config.discovery.serviceId:使用服务名访问配置服务端

spring.cloud.config.uri=http://localhost:1201/:使用uri地址访问配置服务端

spring.cloud.config.profile:当前配置环境,相同配置文件的不同环境,通过profile区分
spring.cloud.config.label:git仓库分支,默认为master

spring.cloud.config.failFast=true:在没有连接配置服务端时直接启动失败,不必等待客户端自身配置的加载完成。

如果配置服务器设置了security安全控制,需要添加用户名密码
spring.cloud.config.username=user
spring.cloud.config.password=123456789






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值