1. 程式人生 > >springcloud Config Server使用 --git

springcloud Config Server使用 --git

首先在github上配置好你的檔案

 

架包

<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>

建立一個springboot專案  裡面配置檔案

eureka:
  client:
    service-url:
     defaultZone:  http://peer1:8761/eureka/
spring:
  application:
    name: config
  cloud:
    config:
      server:
        git:
          uri: 配置檔案git地址
          username: github賬號
          password: github密碼
          #配置存放git到本地檔案地址
          basedir: 存放的git資原始檔到本地的路徑
server:
  port: 7002

啟動類加上

@EnableDiscoveryClient
@EnableConfigServer     註解

啟動後訪問

http://localhost:7002/order-a.properties   order-a.properties是在git上建立的檔案