SpringCould Config
随着业务的增长和功能的完善,对于springboot 的配置文件 application.properties 或application.yml文件管理越来越困难。为了对springcould 的各个子项目的配置文件统一管理,springcould 提供了config 管理的模块。springcould config 配置中心。
目标:
创建springcloud 配置中心模块,用github 统一管理配置文件。springboot 应用程序通过 springcloud 配置中心模块访问github 的配置文件。
步骤:
- 申请和拥有一个github 账号,并在本地安装git 客户端, 在github 上创建一个SpringCloud 的项目,目的是把配置文件提交到此目录的子目录进行统一管理。
2.在本地电脑创建文件夹并把SpringCloud 项目clone 到本地电脑。
clone 命令: git clone remote url
git clone https://github.com/Jason954242100/SpringCloud.git
3.在SpringCloud 文件夹下创建 config_properties文件夹并创建Application相关文件。
文件的内容为:
4.把文件用git 客户端提交到github 。
git 命令 : git add , git commit , git push
5. 创建config server 模块 SpringBootConfigServer.
5.1 创建一个springboot 项目并在pom 文件中加入config 依赖的支持。
<?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