配置中心之 Spring Cloud Config

•Spring Cloud分佈式配置服務由服務器端和客戶端共同組成,Server端提供配置信息的存儲管理,客戶端完成配置信息的調度html

•spring Cloud Config項目提供了一個解決分佈式系統的配置管理方案。它包含了Client和Server兩個部分。git

•Spring Cloud Config Sever的管理Git,svn, native的外部配置,集中配置到全部客戶端。github

•Spring Cloud Config Client根據Spring框架的Environment和PropertySource從Spring Cloud Config Sever獲取配置。web

•資源信息遵循以下規則:
/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
 /{label}/{application}-{profile}.properties
/application.propertiesspring

Server安全

<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-config-server</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-eureka</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-security</artifactId>
		</dependency>
		<dependency>
			<groupId>org.jolokia</groupId>
			<artifactId>jolokia-core</artifactId>
		</dependency>
spring.cloud.config.server.native.searchLocations=file:E://git//config-repo//config
#git 配置
spring.cloud.config.server.git.uri=https://github.com/zhaoqilong3031/sprng-config-repo.git
spring.cloud.config.server.git.searchPaths={application}
spring.cloud.config.server.git.cloneOnStart=true
spring.cloud.config.server.git.username=git@user.com
spring.cloud.config.server.git.password=password

#系統
server.port=7071
server.context-path=/
server.uri-encoding=utf-8
spring.application.name=config
management.context-path=/management
management.address=127.0.0.1
info.app.name=${spring.application.name}
info.app.profiles=${spring.profiles.active}
info.app.version=@project.version@
#native 本地  native , git server
spring.profiles.active=git

#安全
security.basic.enabled=false
security.user.name=test
security.user.password=test
security.ignored=/management/**

 

client服務器

<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-config-client</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
spring.cloud.config.name=${spring.application.name}
spring.cloud.config.profile=@spring.cloud.config.profile@
spring.cloud.config.label=master
spring.cloud.config.uri=@spring.cloud.config.uri@
spring.cloud.config.username=@spring.cloud.config.username@
spring.cloud.config.password=@spring.cloud.config.password@
spring.cloud.config.failFast=true
spring.profiles.active=@env@

詳細匹配可參考https://springcloud.cc/spring-cloud-config-zhcn.htmlapp

相關文章
相關標籤/搜索