SpringCloud 설정 센터 Config 프로 세 스 분석

1.설정 센터 란 무엇 인가
설정 을 통일 적 으로 관리 하고,각 환경의 설정 을 빠르게 전환 합 니 다.
관련 제품:
바 이 두 의 discont
   https://github.com/knightliao/disconf
아 리 의 다이아몬드
   https://github.com/takeseem/diamond
springcloud 의 configs-server:
   http://cloud.spring.io/spring-cloud-config/
2.의존 도 추가

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
3.클래스 시작 에 주석 추가@EnableConfigServer

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;

@SpringBootApplication
@EnableConfigServer
public class ConfigServiceApplication {

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

}
4.application.yml 설정 수정

server:
 port: 9100
eureka:
 client:
  serviceUrl:
   defaultZone: http://localhost:8761/eureka/

spring:
 application:
  name: config-server
 cloud:
  config:
   server:
    git:
     #    ,  git
     uri: https://gitee.com/YTHeng/config_cloud
     #git            ,         
     username: [email protected]
     password: 12345678.
     #    
     timeout: 5
     #  
     default-label: master
5.코드 클 라 우 드 서버 에 새 창고 와 파일 만 들 기

6.방문 주소
http://localhost:9100/master/product-service-dev.yml
경로 접근 방식
/{name}-{profiles}. properties
/{name}-{profiles}.yml
/{name}-{profiles}.json
/{label}/{name]-{profiles].yml
name:서버 이름
profile:환경 이름,개발,테스트,생산
Lable:창고 분기,기본 master 분기
첨부:

이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기