SpringCloud----Config使用

2.3 搭建分布式配置中心

  • 创建SpringBoot应用,添加依赖

 

 

 

配置yml

 

server:
  port: 8888

spring:
  application:
    name: config-server
  cloud:
    config:
      server:
        git:
          uri: https://gitee.com/nz1902/SpringCloud-demo1-config.git
          search-paths: files
          username: 3163779211@qq.com
          password: admin123

eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka

 

 

在启动类添加@@EnableEurekaClient@EnableConfigServer注解

@SpringBootApplication
@EnableEurekaClient
@EnableConfigServer
public class ConfigServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConfigServerApplication.class, args);
    }

}

 

 

 

 

 

 

 

2.4 服务连接到配置中心

  • 在具体的服务应用中添加依赖(config client)

  • <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-config</artifactId>
    </dependency>

     

配置yml连接到分布式配置中心

spring:
  cloud:
    config:
      uri: http://localhost:8888
      name: goods-provider
      label: master
      #profile:dev

 

posted @ 2020-07-19 15:12  beFuckingRich  阅读(104)  评论(0编辑  收藏  举报