spring cloud 读取配置中心
一、配置中心服务:
- pom文件添加依赖:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
- yml配置文件:
spring:
application:
name: config-center
cloud:
config:
server:
git:
uri: http://10.0.0.000:10000/root/config.git ## 配置中心的git地址,存放各种配置文件
username: root ## 该git项目的账户
password: 123456 ## 该git项目的密码
profiles:
active: pro
server:
port: 1111 ##配置中心的端口
- 启动类添加注解EnableConfigServer,表明该服务是配置中心:
@SpringBootApplication
@EnableConfigServer
public class ConfigCenterApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(ConfigCenterApplication.class, args);
}
@Override
protected Sp