Spring Boot Starter (iv) Config Server Unified Configuration Center for MicroServices

Source: Internet
Author: User

I. Directory structure

Two, pom file
<!--Configuration service dependent-        <dependency>            <groupId>org.springframework.cloud</groupId>            <artifactId>spring-cloud-config-server</artifactId>        </dependency>        <!--Eureka Client Dependent-        <dependency>            <groupId>org.springframework.cloud</groupId>            < Artifactid>spring-cloud-starter-eureka</artifactid>        </dependency>
<dependencyManagement>        <dependencies>            <dependency>                <groupId> Org.springframework.cloud</groupid>                <artifactId>spring-cloud-dependencies</artifactId>                <version>${spring-cloud.version}</version>                <type>pom</type>                <scope> import</scope>            </dependency>        </dependencies>    </dependencymanagement >

Spring-cloud-dependencies move to Pom file in Microservice

Third, the configuration of Yml 1.bootstrap.yml
Spring:  profiles:    native  #配置服务器使用本地配置, default git configuration  application:    Name:micro -service-Config # service name registered in Eureka    Eureka:  instance:    non-secure-port: ${server.port:8763 The value in environment variable is used in the environment variable , if not, the default 8080 port    metadata-map:      instanceId: ${ Spring.application.name}:${random.value} #配置在Eureka Server ID  client:    service-URL:      Defaultzone:http://localhost1:8761/eureka/,http://localhost2: 8762/ eureka/  #注册到Eureka Server   
2.application.yml
Spring:  Cloud:    config:      server:        native:          search-locations: classpath:/config #配置文件所在位置server:  8763  
Iv. Start Microservice-config
 PackageCom.nc.cloud.microservice.config;Importorg.springframework.boot.SpringApplication;Importorg.springframework.boot.autoconfigure.SpringBootApplication;ImportOrg.springframework.cloud.config.server.EnableConfigServer;Importorg.springframework.cloud.netflix.eureka.EnableEurekaClient, @SpringBootApplication @enableconfigserver//turn on configuration server support@EnableEurekaClient//Turn on Eureka client Support Public classconfigapplication { Public Static voidMain (string[] args) {Springapplication.run (configapplication.class, args); }}

Spring Boot Starter (iv) Config Server Unified Configuration Center for MicroServices

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.