Enterprise distribution Micro-service cloud Springcloud springboot MyBatis (vi) Distributed Configuration Center

Source: Internet
Author: User

First, Introduction

In distributed systems, because of the large number of services, in order to facilitate the unified management of service profiles, real-time updates, so the need for distributed configuration Center components. In spring cloud, there is a distributed Configuration center component, Spring Cloud Config, which enables configuration services to be placed in the memory of the configuration service (that is, local) and also in a remote Git repository. In Spring Cloud Config component, there are two roles, one is config server and the other is config client.
Second, build config Server

Create a Spring-boot project, named Config-server, whose pom.xml:

<?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> <groupId> Com.forezp</groupid> <artifactId>config-server</artifactId> <version>0.0.1-snapshot</  version> <packaging>jar</packaging> <name>config-server</name> <description>demo Project for Spring boot</description> <parent> <groupid>org.springframework.boot</groupid&        Gt        <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> <relativePath/> <!--lookup parent from repository to </parent> <properties> &LT;PR Oject.build.sourceencoding>utf-8</project.build.souRceencoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <j            ava.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactid>spring-cloud-config-server</art ifactid> </dependency> <dependency> <groupid>org.springframework.boot</gr Oupid> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope&        Gt            </dependency> <dependency> <groupId>org.springframework.cloud</groupId>    <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupid>org. SpringframewoRk.cloud</groupid> <artifactId>spring-cloud-dependencies</artifactId> < Version>camden.sr6</version> <type>pom</type> <scope>import</s        cope> </dependency> </dependencies> </dependencyManagement> <build>                <plugins> <plugin> <groupId>org.springframework.boot</groupId>     <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins>            </build> <repositories> <repository> <id>spring-milestones</id>            <name>spring milestones</name> <url>https://repo.spring.io/milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </rep Ository> </repoSitories></project> 

At the entrance of the program application class plus the @enableconfigserver annotation opens the function of the configuration server, the code is as follows:

@SpringBootApplication@EnableConfigServerpublic class ConfigServerApplication {    public static void main(String[] args) {        SpringApplication.run(ConfigServerApplication.class, args);    }}

You need to configure the following in the program configuration file Application.properties file:

spring.application.name=config-serverserver.port=8888spring.cloud.config.server.git.uri=https://github.com/forezp/SpringcloudConfig/spring.cloud.config.server.git.searchPaths=respospring.cloud.config.label=masterspring.cloud.config.server.git.username=your usernamespring.cloud.config.server.git.password=your password
spring.cloud.config.server.git.uri:配置git仓库地址spring.cloud.config.server.git.searchPaths:配置仓库路径spring.cloud.config.label:配置仓库的分支spring.cloud.config.server.git.username:访问git仓库的用户名spring.cloud.config.server.git.password:访问git仓库的用户密码

If the Git warehouse is a public warehouse, you can not fill in the user name and password, if the private warehouse needs to fill out, this example is open warehouse, rest assured that use.

There is a file in the remote repository https://github.com/forezp/SpringcloudConfig/. config-client-dev.properties file has a property:

foo = foo version 3

The schema code is as follows:

Enterprise distribution Micro-service cloud Springcloud springboot MyBatis (vi) Distributed Configuration Center

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.