SpringCould (4) Config-Service local file configuration

reference:

https://xuwujing.blog.csdn.net/article/details/88578076

Introduction:

SpringCloud-Congfig-Service is mainly used for configuration file hot deployment, two ways to achieve git and local file implementation

1. Set up Eurak service center

reference

https://blog.csdn.net/qq_37203082/article/details/111031105

Second, build a Config-Service

maven

<!--        注册到eureke客户端-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>

<!--        config服务器-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>

application.yml configuration file

server:
  port: 8769

spring:
  application:
    name: cmain-config
  profiles:
    active: native
  cloud:
    config:
      server:
        native:
          search-locations: classpath:/share

eureka:
  client:
    serviceUrl:
      #      eureka的注册中心地址
      defaultZone: http://localhost:8888/eureka/

Create a folder under the Resource folder to store the configuration files of other clients

The config content of the client, here is only a configuration registered to the service center

eureka:
  client:
    serviceUrl:
      #      eureka的注册中心地址
      defaultZone: http://localhost:8888/eureka/

 

 

Add a comment on startup

@EnableConfigServer

Three, create a Config client

maven 

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>

Configuration file

server:
  port: 8885

spring:
  application:
    name: client-02
  cloud:
    config:
      name: client-02
      profile: dev
      uri: http://localhost:8769

Special reminder, the configuration file of the client needs to be the bootstrap.yml file

 

Four, inspection

The order of startup is eureka server, config, client

 

 

Guess you like

Origin blog.csdn.net/qq_37203082/article/details/113761661