SpringCloud Config
概念
架构
1.码云-新建配置文件application-zuul-dev.yml
2.新建模块config-server-5000
1.注册到Eureka注册中心
2.集成Config
1.导包
<!--config-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
2.配置类打标签@EnableConfigServer
@EnableConfigServer
3.yml
server:
port: 5000
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: https://gitee.com/dsqzzz/pro4.git #码云仓库
username: 2219726571@qq.com #用户名
password: zzz12345 #密码
eureka:
client:
service-url:
defaultZone: http://peer1:1000/eureka/,http://peer2:1001/eureka/ #连接服务器端
instance:
instance-id: config-server:5000
prefer-ip-address: true #使用ip注册
客户端
1.导包
<!--config-client-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
</dependency>
2.yml文件改名 —bootstrap.yml 优先级提高
#执行配置中心
spring:
cloud:
config:
uri: http://localhost:5000 #配置中心地址
name: application-order
profile: dev