Spring Cloud Cofig配置センター


一、Config配置センター項目を作成する
1.依存関係を追加

 <dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-config-server</artifactId>
 </dependency>
2.始動類は、@EnbleConfigServerを追加する必要があります。

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

/**
 * @author fusw
 */
@SpringBootApplication
@EnableConfigServer
public class ConfigCenterApplication {

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

}
3.プロファイル

eureka.instance.appname=base-iov-config
security.user.name=test
security.user.password=test
# GitLab      ,    .git   
#      git      
spring.cloud.config.server.git.uri=http://xxxx/config-repo.git
# git           ,      , “,”  
spring.cloud.config.server.git.search-paths=*
#    clone            
spring.cloud.config.server.git.basedir=/data/deploy/config-repo
spring.cloud.config.server.git.force-pull=true
# git      
spring.cloud.config.server.git.username=test
# git      
spring.cloud.config.server.git.password=test



#      git       spring.cloud.config.server.git.repos.x.uri, iot  
spring.cloud.config.server.git.repos.iot.uri=http://xxxx/iot/config-repo.git
spring.cloud.config.server.git.repos.iot.search-paths=*
spring.cloud.config.server.git.repos.iot.basedir=/data/deploy/config-repo
spring.cloud.config.server.git.repos.iot.force-pull=true
# git      
spring.cloud.config.server.git.repos.iot.username=test
# git      
spring.cloud.config.server.git.repos.iot.password=test
#       ,         
spring.cloud.config.server.git.repos.iot.pattern=Iot*

#    
eureka.client.serviceUrl.defaultZone=http://xxx/eureka/
二、git保管配置の倉庫
git倉庫を作成して、各項目の配置を保存します。プロジェクトの第一級ディレクトリでプロジェクトによってフォルダを作成できます。
たとえば:
I ot-Test Project-dev.yml
I ot-Test Project-prd.yml
I ot-Test Project-test.yml
test.ymlのようなデフォルトの設定は避けたほうがいいです。各項目のプロファイルにspring.profiles.activeの指定で使用されているプロファイルがない場合、デフォルトのプロファイルがロードされます。
三、各SprigCloudのプロジェクト配置アクセス配置センター
resourceでのbootstrap.propertiesプロファイルでは、配置センターの関連配置は以下の通りです。

#            
spring.cloud.config.name=TestProject
#   iot       
#spring.cloud.config.name=Iot-TestProject
#           ,        ,            :TestProject -test.yml
spring.cloud.config.profile=test


#             git  
spring.cloud.config.label=master

spring.cloud.config.username=test
spring.cloud.config.password=test

#    Config       
spring.cloud.config.discovery.enabled=true
#    Server    name,    Server   spring.application.name   
spring.cloud.config.discovery.serviceId=base-iov-config

以上が本文の全部です。皆さんの勉強に役に立つように、私たちを応援してください。