Spring Cloud Cloud Service architecture-commonservice-config Configuration service Setup

Source: Internet
Author: User

  • Introduced
    Spring Cloud Config provides server and client support for external configurations in distributed systems. With config Server, you can manage the external properties of your application in all environments. The conceptual mappings on the client and server are the same as the spring environment and propertysource abstractions, so they fit well with spring applications, but can be used with any application running in any language. As your application passes through the deployment process from developer to test and production, you can manage the configuration between these environments and determine everything that your application needs to run when it is migrated. The default implementation of the server storage backend uses git, which makes it easy to support the configuration environment for the label version and access to the various tools for managing content. It is easy to add an alternative implementation and insert it using the spring configuration.

  • Introduce the POM-related jar package, where Pom.xml is configured as follows:
  • <?xml version= "1.0" encoding= "UTF-8"?> <project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "http ://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" http://maven.apache.org/POM/4.0.0http:// Maven.apache.org/xsd/maven-4.0.0.xsd "> <modelVersion>4.0.0</modelVersion> <parent>< Groupid>com.ml.honghu</groupid> <artifactId>commonservice</artifactId> <version>0.0.1 -snapshot</version> </parent><artifactId>commonservice-config</artifactId> <packaging >jar</packaging> <name>commonservice-config</name><description>config server</ description> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency> <dependency>< Groupid>org.springframework.cloud</groupid> <artifactid>spring-cloud-starter-eureka</ Artifactid> </dependenCy><dependency> <groupId>org.springframework.boot</groupId> <artifactId> Spring-boot-starter-security</artifactid></dependency> <dependency> <groupId> Org.springframework.boot</groupid> <artifactId>spring-boot-starter-test</artifactId> <scope >test</scope> </dependency> </dependencies> <build> <plugins> <plugin>< Groupid>org.springframework.boot</groupid> <artifactid>spring-boot-maven-plugin</artifactid > <executions> <execution><id>1</id> <goals> <goal>repackage</goal> </goals> </execution> <execution> <id>2</id> <goals> <goal>build-info< /goal></goals> </execution> </executions> </plugin> </plugins> </build> </ Project>

      1. Configapplication.java boot file configuration in Src/main/java:

    Package Com.ml.honghu; Import org.springframework.boot.SpringApplication; Import org.springframework.boot.autoconfigure.SpringBootApplication; Import Org.springframework.cloud.config.server.EnableConfigServer; Import org.springframework.cloud.netflix.eureka.EnableEurekaClient; @EnableConfigServer @[email protected] public class Configapplication {public static void main (string[] args) {Springapp Lication.run (Configapplication.class, args); } }

      1. BOOTSTRAP.YML Configuration under Src/main/resource

    server:port:8888 spring:application:name:commonservice-config-server profiles:active:discovery,native Cloud: Config:server:git:uri:http://192.168.0.254/honghu.../honghu-config.git Username:honghu Password: 123456searchpaths:config-dev security:basic:enabled:true User:name:honghu password:123456 eureka:client:serviceUr L:defaultzone:http://honghu:[ Email protected] : 8761/eureka/honghuzone:http://honghu:[email protected] : 8761/eureka/registry-fetch-interval-seconds: Availability-zones:honghu:honghuzone instance:prefer-ip-address:truemetadatamap:version:1.0 variant:a User: ${s Ecurity.user.name} password: ${security.user.password} management:security:enabled:false
    Note: If you do not load the profile information from a remote git or SVN repository, you can configure the load local address, such as window under configuration using:

    server:port:8888 spring:application:name:commonservice-config-server profiles:active:discovery,native Cloud: Config:server: <span style= "color: #ff0000;" >native.searchLocations:d:/honghu-config</span> security:basic:enabled:true User:name:honghu Password: 123456 Eureka:client:serviceurl:defaultzone:http://honghu:[email protected]: 8761/eureka/honghuzone:http ://honghu:[email protected]: 8761/eureka/registry-fetch-interval-seconds:300 Availability-zones:honghu: Honghuzone instance:prefer-ip-address:true metadatamap:version:1.0 variant:a User: ${security.user.name} password: ${ Security.user.password} management:security:enabled:false
    To this, the entire Config service project configuration is complete!!

    Spring Cloud Cloud Service architecture-commonservice-config Configuration service Setup

    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.