spring cloud config SpringCloud-Config

Spring boot: V2.0.6

1. Config Server

1) pom

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

2) yml

    application.yml

server:
  port: 8888
  
spring:
  cloud:
    config:
      server:
        git:
          uri: https://gitee.com/xiaobin80/spring-cloud-config-repo

3) ON

Add Annotations:

@EnableConfigServer

test:

访问git repo中的yml文件。

格式:主机+git文件名/default

例如:

http://localhost:8888/springcloud-eureka-service/default

2. Config Client

1) pom

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

2) yml

bootstrap.yml

spring:
  application:
    name: springcloud-eureka-service
  cloud:
    config:
      uri: http://localhost:8888

3) business suit

   For more information, please refer to  "demo-jpa-spring-boot2-mysql"

test:

http://localhost:8790/user/list

Reference:

    1. 《Spring Cloud实战(一)-Spring Cloud Config Server

    2. 《SpringCloud-Config

猜你喜欢

转载自www.cnblogs.com/xiaobin-hlj80/p/9912494.html
今日推荐