Spring Cloud Config 使用SVN 和 git方式的相關配置

文件的存儲方式:git

 

一、使用svn 當作配置中心 config server的配置方式:web

     引入svn的包spring

<dependency>
   <groupId>org.tmatesoft.svnkit</groupId>
   <artifactId>svnkit</artifactId>
   <version>1.8.10</version>
</dependency>

   修改application.ymlbootstrap

   個人svn路徑是  http://ip:port/svn/mogo/Coding/app-hotpoint-parent/app-global-config/config-repoapp

spring:
  application:
    name: app-provider-config
  cloud:
    config:
      enabled: true
      server:
        svn:
          uri: http://ip:port/svn/mogo/Coding/app-hotpoint-parent/app-global-config
          username: username
          password: password
          default-label: config-repo
  profiles:
    active: subversion

config  client 的配置 ide

bootstrap.ymlsvn

spring:
  application:
    name: config-client  # 這裏要跟文件(config-client-dev.yml)的前面的application段相同
  cloud:
    config:
      label: config-repo
      uri: http://localhost:7805
      name: config-client
  profiles:
    active: dev

至於其他的端口什麼的,放在application.yml中便可spring-boot

二、使用git 當作文件存儲方式spa

 

 config server 的 application.ymlcode

spring:
  application:
    name: app-provider-config
  cloud:
    config:
      server:
        git:
          uri: git@code.aliyun.com:.............
          search-paths: config-repo/div,config-repo/test
          username: username
          password: password
      label: master

logging:
  level:
    org.springframework.boot.env.PropertySourcesLoader: TRACE
    org.springframework.cloud.config.server: DEBUG

server:
  port: 7805
eureka:
  client:
    serviceUrl:
      defaultZone: ...........
  instance:
    ip-address: true
    instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}

config client  的 bootstrap.yml

spring:
  application:
    name: app-provider-ams
  cloud:
    config:
      label: master
      uri: http://localhost:7805
      discovery:
        enabled: true
        service-id: app-provider-config
      fail-fast: true
  profiles:
    active: dev
eureka:
  client:
    serviceUrl:
      defaultZone: ..........
  instance:
    ip-address: true
    instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}
management:
  endpoints:
    web:
      exposure:
        include: refresh,health,info

 

單點刷新

須要引入

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
            <version>2.0.5.RELEASE</version>
        </dependency>

2.0 版本以上須要加一下

management:
  endpoints:
    web:
      exposure:
        include: refresh,health,info

 接下來刷新路徑是 /actuator/refresh

相關文章
相關標籤/搜索