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 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> <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> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <ar Tifactid>spring-boot-starter-security</artifactid></dependency> <dependency> <gr Oupid>org.springframework.boot</groupid> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> &L T;plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> < ;execution> <id>1</id> <goals> <goal>repackage</goal> </goals> </execution> <e Xecution> <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:
PackageCom.ml.honghu;ImportOrg.springframework.boot.SpringApplication;ImportOrg.springframework.boot.autoconfigure.SpringBootApplication;ImportOrg.springframework.cloud.config.server.EnableConfigServer;ImportOrg.springframework.cloud.netflix.eureka.EnableEurekaClient, @ Enableconfigserver@enableeurekaclient@springbootapplication Public classconfigapplication{ Public Static voidMain (string[] args) {Springapplication.run (configapplication.class, args); } }
4. BOOTSTRAP.YML Configuration under Src/main/resource
server:port:8888Spring:application:name:commonservice-config-Server Profiles:active:discovery,nativecloud:config:server:git:uri:http://192.168.0.254/honghu.../honghu-config.git Username:honghu password:123456 searchpaths: Config-dev Security:basic:EnabledtrueUser:name:honghu Password:123456eureka: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:truemetadatamap:version:1.0variant:a User: ${security.user.name} password: ${security.user.password} management:security: Enabled:falseNote: If you do not load the profile information from a remote git or svn library, you can configure the load local address, such as window under configuration using: Server:port:8888Spring:application:name:commonservice-config-Server Profiles:active:discovery,nativeCloud:config:server:<span style= "color: #ff0000;" >native.searchlocations:d:/honghu-config</span>security:basic:enabled:trueUser:name:honghu Password:123456eureka: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:truemetadatamap:version:1.0variant:a User: ${security.user.name} password: ${security.user.password} management:security: Enabled:false
To this, the entire Config service project configuration is complete!! more detailed source code source full project source technical support 1791743380
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.
Spring cloud-Honghu Cloud distributed micro-service clouds system-config (vii)