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. Conceptual mapping on client and server with Spring environment
and propertysource
abstractions are the same, so they fit well with spring applications, but can be used with any application that runs 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>commonservice-config</ artifactid> &Nbsp;<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> &nBsp; <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>
3. 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); } }
4. 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 : &NBSP;TRUE&NBSP;&NBSP;&NBSP;&NBsp;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
Note: If you do not load profile information from a remote git or SVN repository, you can configure the load-local address, for example, under Window configuration:
server: port: 8888 spring: application: name: commonservice-config-server profiles: active: discovery,native cloud: config: server: native.searchlocations: d:/honghu-configsecurity: 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 has been configured!!
from now on, my side will be developing a recent Springcloud the process and essence of micro-service cloud architecture is documented to help more interested in developing Spring Cloud frame of friends, hope can help more good scholars. let's explore how the Spring Cloud architecture is built and how it can be used in the industry. Source of information source
Integrated Spring Cloud Cloud service architecture-commonservice-config Configuration service Build