Spring Cloud-鸿鹄Cloud分布式微服务云系统—Config(七)

1.    介绍

Spring Cloud Config 为分布式系统中的外部配置提供服务器和客户端支持。使用 Config Server,您可以在所有环境中管理应用程序的外部属性。客户端和服务器上的概念映射与Spring Environment和PropertySource抽象相同,

因此它们与 Spring 应用程序非常契合,但可以与任何以任何语言运行的应用程序一起使用。随着应用程序通过从开发人员到测试和生产的部署流程,您可以管理这些环境之间的配置,并确定应用程序具有迁移时需要运行的一切。服务器存储后端的默认实现使用 git,因此它轻松支持标签版本的配置环境,以及可以访问用于管理内容的各种工具。很容易添加替代实现,并使用 Spring 配置将其插入。

2.    引入 pom 相关 jar 包,其中 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.ml.honghu</groupId>
        <artifactId>commonservice</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>commonservice-config</artifactId>
    <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>
            <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.    在src/main/java进行ConfigApplication.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.    在 src/main/resource 下进行 bootstrap.yml 配置

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:
    enabled: false
注意: 如果不从远程 git 或者 svn 库加载配置文件信息,可以配置加载本地地址,比如 window 下配置使用:
server:  port: 8888 spring:   application:
    name: commonservice-config-server
  profiles:
    active: discovery,native   cloud:     config:       server:
<span     style="color:     #ff0000;">native.searchLocations: d:/honghu-config</span>
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:
enabled: false 

到此,整个 config 服务项目配置完毕!!更多详细源码参源完整项目的源码来源 技术支持1791743380

从现在开始,我这边会将近期研发的 spring cloud 微服务云架构的搭建过程和精髓记录下来,帮助更多有兴趣研发 spring cloud 框架的朋友,大家来一起探讨 spring cloud 架构的搭建过程及如何运用于企业项目。

原文地址:https://www.cnblogs.com/sccoming/p/8715750.html

时间: 2024-08-30 14:05:57

Spring Cloud-鸿鹄Cloud分布式微服务云系统—Config(七)的相关文章

Spring cloud--Hong hu Cloud分布式微服务云系统—Config

介绍 Spring Cloud Config 为分布式系统中的外部配置提供服务器和客户端支持.使用 Config Server,您可以在所有环境中管理应用程序的外部属性.客户端和服务器上的概念映射与Spring Environment和PropertySource抽象相同, 因此它们与 Spring 应用程序非常契合,但可以与任何以任何语言运行的应用程序一起使用.随着应用程序通过从开发人员到测试和生产的部署流程,您可以管理这些环境之间的配置,并确定应用程序具有迁移时需要运行的一切.服务器存储后端

Spring cloud--鸿鹄Cloud分布式微服务云系统—Config

介绍 Spring Cloud Config 为分布式系统中的外部配置提供服务器和客户端支持.使用 Config Server,您可以在所有环境中管理应用程序的外部属性.客户端和服务器上的概念映射与Spring Environment和PropertySource抽象相同, 因此它们与 Spring 应用程序非常契合,但可以与任何以任何语言运行的应用程序一起使用.随着应用程序通过从开发人员到测试和生产的部署流程,您可以管理这些环境之间的配置,并确定应用程序具有迁移时需要运行的一切.服务器存储后端

Spring Coud--鸿鹄Cloud分布式微服务云系统

简介鸿鹄云Cloud是基于SpringCloud来封装的,是一系列框架的有序集合.利用Spring Boot的开发模式简化了分布式系统基础设施的开发,如服务发现.注册.配置中心.消息总线.负载均衡.断路器.数据监控等(这里只简单的列了一部分),都可以用Spring Boot的开发风格做到一键启动和部署.鸿鹄云Cloud将目前比较成熟.经得起实际考验的服务框架组合起来,通过Spring Boot风格进行再封装,屏蔽掉了复杂的配置和实现原理,最终整合出一套简单易懂.易部署和易维护的分布式系统架构平台

Spring Cloud--鸿鹄Cloud分布式微服务云系统—技术点

鸿鹄Cloud是基于springcloud的,spring cloud本身提供的组件就很多,但我们需要按照企业的业务模式来定制企业所需要的通用架构,那我们现在需要考虑使用哪些技术呢?下面我针对于spring cloud微服务分布式云架构做了以下技术总结:View: H5.Vue.jsSpring Boot/Spring Cloud:Zuul.Ribbon.Feign.Turbine.Hystrix.Oauthor2.Sleuth.API Gateway.Spring Cloud.Config E

Spring Coud--鸿鹄Cloud分布式微服务云系统(一)

简介 鸿鹄云Cloud是基于SpringCloud来封装的,是一系列框架的有序集合.利用Spring Boot的开发模式简化了分布式系统基础设施的开发,如服务发现.注册.配置中心.消息总线.负载均衡.断路器.数据监控等(这里只简单的列了一部分),都可以用Spring Boot的开发风格做到一键启动和部署.鸿鹄云Cloud将目前比较成熟.经得起实际考验的服务框架组合起来,通过Spring Boot风格进行再封装,屏蔽掉了复杂的配置和实现原理,最终整合出一套简单易懂.易部署和易维护的分布式系统架构平

Spring Cloud-Honghu Cloud分布式微服务云系统—技术点

摘要: 下面我针对于spring cloud微服务分布式云架构做了以下技术总结: View: H5.Vue.js Spring Boot/Spring Cloud: Zuul.Ribbon.Feign.Turbine.Hystrix.Oauthor2.Sleuth.API Gateway.Spring Cloud.Config Eureka.SSO.Spring Cloud. BUS.Turbine.Zipkin.Cache.Spring Cloud Admin.API Gateway.ELK

Spring Cloud-honghu Cloud分布式微服务云系统

摘要: SpringCloud的子项目,大致可分成两类: 一类是对现有成熟框架Spring Boot的封装和抽象,也是数量最多的项目: 第二类是开发了一部分分布式系统的基础设施的实现,如SpringCloud Stream就是kafka, ActiveMQ这样的角色.开发人员进行微服务的实践,第一类子项目就已经足够使用简介 鸿鹄云Cloud是基于SpringCloud来封装的,是一系列框架的有序集合.利用Spring Boot的开发模式简化了分布式系统基础设施的开发,如服务发现.注册.配置中心.

Spring Cloud-Honghu Cloud分布式微服务云系统(一)

简介 鸿鹄云Cloud是基于SpringCloud来封装的,是一系列框架的有序集合.利用Spring Boot的开发模式简化了分布式系统基础设施的开发,如服务发现.注册.配置中心.消息总线.负载均衡.断路器.数据监控等(这里只简单的列了一部分),都可以用Spring Boot的开发风格做到一键启动和部署.鸿鹄云Cloud将目前比较成熟.经得起实际考验的服务框架组合起来,通过Spring Boot风格进行再封装,屏蔽掉了复杂的配置和实现原理,最终整合出一套简单易懂.易部署和易维护的分布式系统架构平

Spring Cloud--鸿鹄Cloud分布式微服务云系统—技术点(二)

鸿鹄Cloud是基于springcloud的,spring cloud本身提供的组件就很多,但我们需要按照企业的业务模式来定制企业所需要的通用架构,那我们现在需要考虑使用哪些技术呢? 下面我针对于spring cloud微服务分布式云架构做了以下技术总结: 欢迎大家一起学习研究相关技术愿意了解源码的朋友直接求求交流分享技术:2147775633 View: H5.Vue.js Spring Boot/Spring Cloud:Zuul.Ribbon.Feign.Turbine.Hystrix.O