zoukankan      html  css  js  c++  java
  • Spring Cloud Config 搭建Config 服务

    配置中心:

    1. open API
    2. 配置生效监控
    3. 一致性的K-V存储
    4. 统一配置的实时推送
    5. 配置全局恢复、备份、历史版本
    6. 高可用集群

    通过config 获取配置,流程:

    下面介绍,基于spring cloud config配置中心管理配置的使用,config配合Git,Svn,Mysql 等配合使用,本示例基于Config+Git:

    基于父工程创建config工程(my-cloud-config):

    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>
        <parent>
            <groupId>com.springcloud.</groupId>
            <artifactId>eureka-test</artifactId>
            <version>1.0-SNAPSHOT</version>
        </parent>
        <groupId>com.cloud.my</groupId>
        <artifactId>my-cloud-config</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>my-cloud-config</name>
        <description>Demo project for Spring Boot</description>
    
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-config-server</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
        </dependencies>
    
    </project>

    启动类:

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

    配置文件:

    spring.cloud.config.server.git.uri=https://github.com/shiguota/spring-cloud-config.git
    spring.cloud.config.server.git.search-paths=my-cloud-config
    spring.application.name=my-cloud-config
    server.port=1001

     启动程序会输出如下日志:

    通过日志显示的路径格式访问即可获取Git中的配置文件具体的配置;

  • 相关阅读:
    跳出iframe
    leetcode 225. Implement Stack using Queues
    leetcode 206. Reverse Linked List
    leetcode 205. Isomorphic Strings
    leetcode 203. Remove Linked List Elements
    leetcode 198. House Robber
    leetcode 190. Reverse Bits
    leetcode leetcode 783. Minimum Distance Between BST Nodes
    leetcode 202. Happy Number
    leetcode 389. Find the Difference
  • 原文地址:https://www.cnblogs.com/shiguotao-com/p/10420302.html
Copyright © 2011-2022 走看看