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 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.
- 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> <g Roupid>com.ml.honghu</groupid> <artifactId>commonservice</artifactId> <version>0. 0.1-snapshot</version> </parent> <artifactId>commonservice-config</artifactId> <packag ing>jar</packaging> <name>commonservice-config</name> <description>config server</ description> <dependencies> <dependency> <groupid>org.springframework.cloud</ Groupid> <artifactId>spring-cloud-config-server</artifactId> </dependency> & Lt;dependency> <groupid>org.springFramework.cloud</groupid> <artifactId>spring-cloud-starter-eureka</artifactId> </de Pendency> <dependency> <groupid>org.springframework.boot</groupid><artifactid>spring- Boot-starter-security</artifactid></dependency> <dependency> <groupid>org.spring Framework.boot</groupid> <artifactId>spring-boot-starter-test</artifactId> <sco pe>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactid& Gt;spring-boot-maven-plugin</artifactid> <executions> <execution> <id>1</id> <goals> <goal>repa Ckage</goal> </goals> </execution> <execution> <id>2</id> & lt;goals><goal>build-info</goal> </goals> </execution> </executions> </plugin> </plugins> </build></project>
- 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);
- 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 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:
Note: If you do not load the profile information from a remote git or svn library, you can configure the load local address, such as the configuration using Windows:
To this, the entire Config service project configuration is complete!!
From now on, I will be documenting the process and essence of the recent development of the spring cloud micro-service cloud architecture to help more friends who are interested in developing the Spring cloud framework to explore the process of building the spring cloud architecture and how to use it in enterprise projects. Enterprise distributed micro-service Cloud Architecture technology Spring cloud+spring boot+mybatis+shiro+restful+ Micro-service source sharing, technical support 1791743380
Spring cloud--hong Hu Cloud distributed micro-service cloud system-config