1.统一配置中心config
1.config-server 导入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
2.config-server 主类上加注解 @EnableConfigServer
3.配置yml文件
spring:
cloud:
config:
server:
git:
uri: https://gitee.com/songqq123/config-repo
username: 431901509@qq.com
password: song1003
basedir: D:\config2
4.config-client导入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
</dependency>
5.配置bootstrap.yml文件
spring:
application:
name: product
cloud:
config:
discovery:
enabled: true
service-id: config
profile: dev
eureka:
client:
service-url:
defaultZone: http://localhost:8762/eureka/
6.补充知识:
/{name}-{profiles}.yml
/{label}/{name}-{profiles}.yml
name 服务名
profiles 环境
label 分支