springCloud加载配置文件

1.优先级问题

	bootstrap.yml优先级高于其他配置文件

2.springcloud配置中心

1.springcloud-configservice
	1.启动类上加开启config组件:@EnableConfigServer
	2.集中加载config配置
2.springcloud-configclient
	1.定义配置文件为bootstrap.yml
spring:
  application:
    name: hellxztest                     #指定了配置文件的应用名
  cloud:
    config:
      uri: http://localhost:7001/        #Config server的uri
      profile: dev                       #指定的环境
      label: master                      #指定分支
	2.

集中式config加载的几种方式:

	1、config 默认Git加载
	通过spring.cloud.config.server.git.uri指定配置信息存储的git地址,比如:https://github.com/spring-cloud/config
	2、加载本地开发环境
	### config server native
	spring.profiles.active=native
	spring.cloud.config.server.native.searchLocations=classpath:/config
	3、加载 本地物理环境
	spring.profiles.active=native
	spring.cloud.config.server.native.searchLocations=file:E:\\Java\\Workspaces\\sts\\doc\\file\\config
	 
	4、加载svn环境  http://localhost:8888/{application}/{profile}/{label},比如:http://localhost:8888/dmeo/development/trunk
	### config server svn
	spring.cloud.config.server.svn.uri=http://localhost:8888/dmeo/development/trunk
	spring.cloud.config.server.svn.username=xxx
	spring.cloud.config.server.svn.password=xxx
	spring.profiles.active=subversion
	 
	 特别注意  svn 环境 需要 引入 SVN jar包 
	
	<groupId>org.tmatesoft.svnkit</groupId>
	<artifactId>svnkit</artifactId>

3,eureka配置

	eureka
		client
			fetch-registry: true  #获取注册表
			register-with-eureka: true #注册当前服务到eureaka-service
			registry-fetch-interval-seconds: 10  #获取服务列表间隔时间
			serviceUrl:
				defaultZone:http://域名:端口/eureka/
			
		servce
			enable-self-preservation: false #禁用自我保护模式,默认开启
			eviction-interval-timer-in-ms: 7000 # 清理间隔(单位毫秒,默认是60*1000)     
		instance  #实例
			hostname: 域名
			prefer-ip-address: true  #是否以ip地址进行注册,默认为false
			lease-renewal-interval-in-seconds: 5 #发送心跳包间隔
			lease-expiration-duration-in-seconds: 20 #发呆时间,即失效时间。超过该时间当前实例被列入待清理实例,等待清理
		
 关键词
 	是否以ip地址注册:
   	 	通过注册名即spring.application.name访问时:
   	 	如果prefer-ip-address: true
   	 		http://171.26.215.8:5001/info
   	 	如果prefer-ip-address: false
   	 		http://localhost:5001/info
	自我保护模式:
		eureka
   			servce
				enable-self-preservation: true #开启自我保护模式
				renewal-percent-threshold: 0.85  #阀值比例默认0.85
		*接收不到大量的心跳包时,表示网络原因,默认开启自我保护模式;不会清除请求实例
		*接收不到少量心跳包时,认为eureka-client挂掉,不会开启保护 机制。

	Renews threshold: Eureka Server期望每分钟收到客户端实例续约的总数
	=2*服务器数量(2:一分钟默认发送2次心跳包)
	Renews(last min): Eureka Server最后一分钟收到客户端实例续约的总数
	
	当预期<实际(保护机制激活)

		假设现在有1个eureka-service   2个eureka-client
		Renews threshold=renewalPercentThreshold*2*(2+1)=5 (向下取整) {renewalPercentThreshold:阀值比例,2:默认心跳包数,2个eureka-cli,1个eureka-server:其实也可看成eurekaclient}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值