springcloud Config Server使用 --git

版权声明:本文为博主原创文章,未经博主允许不得转载(转载请声明原文地址,谢谢java交流群:553997290) https://blog.csdn.net/qq_39313596/article/details/83657785

首先在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上创建的文件

 

猜你喜欢

转载自blog.csdn.net/qq_39313596/article/details/83657785