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

Source: Internet
Author: User

1. Introduction

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.

2. 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.0 Http://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>commonservic E-config</artifactid> <packaging>jar</packaging> <name>commonservice-config< /name> <description>config server</description> <dependencies> &LT;DEP Endency> <groupId>org.springframework.cloud</groupId> <artifactid>s Pring-cloud-config-server</artifactid> </dependency> <dependency> <groupid>org.spri              Ngframework.cloud</groupid> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupid>org.springframework.boo                  T</groupid> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupid>org.springframework.boot</group Id> <artifactId>spring-boot-starter-test</artifactId> &LT;SCOPE&GT;TEST&L t;/scope> </dependency> </dependencies> <build> <plu                      Gins> <plugin> <groupId>org.springframework.boot</groupId> <artIfactid>spring-boot-maven-plugin</artifactid> <executions> &L                                  T;execution> <id>1</id> <goals>                          <goal>repackage</goal> </goals>                                              </execution> <execution>                                                         <id>2</id> <goals> <goal>build-info</goal> &LT;/GOALS&G                                          T           </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      @EnableEurekaClient      @SpringBootApplication      public class ConfigApplication {                public static void main(String[] args) {              SpringApplication.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:123456          Searchpaths:config-dev security:basic:enabled:true User:name:honghu password:123456 Eureka:client:serviceurl:defaultzone:http://honghu:[email protec Ted]:8761/eureka/honghuzone:http://honghu:[email protected]:8761/eureka/registry-fetch-interva l-seconds:300 Availability-zones:honghu:honghuzone Instance:prefer-ip-address:tru E metadatamap:version:1.0 variant:a User: ${security.user.name} pa ssWOrd: ${security.user.Password} management:security:enabled:false       

Note: If you do not load profile information from a remote git or svn library, you can configure the load local address, for example, under Window configuration using:

  8888 Spring:application:name:commonservice-config-server profiles:acti Ve: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: ${s Ecurity.user.name} password: ${security.user.password} management:security:enabled:fals E  

Source source technical support for complete projects 1791743380

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.