SpringCloud Config Server



SpringCloud Config Server

步骤1: 使用Spring Initializr创建一个Maven项目 https://start.spring.io/
步骤2: 选择Spring Boot版本
2.2 .0 M6 或更高版本。不要选择快照版本。
步骤3: 提供
Group名称。在我们的示例中,为
com.lidihuo.microservices。
步骤4: 提供
Artifact id。我们提供了
spring-cloud-config-server。

SpringCloud Config Server_https://bianchenghao6.com_【SpringCloud 教程】_第1张

步骤5: 添加
Spring Boot DevTools
Config Server 依赖性。

SpringCloud Config Server_https://bianchenghao6.com_【SpringCloud 教程】_第2张

步骤6: 点击
生成项目按钮。将下载一个zip文件,并将其解压缩到硬盘中。
步骤7: 现在,打开
eclipse。导入下载的maven项目。它将下载所需的文件。
在下一步中,我们将创建一个简单的Git存储库,并配置spring cloud配置服务器以从特定的Git存储库中获取值。我们需要安装本地Git。

安装Git并创建本地存储库

步骤1: 从 https://git-scm.com/并安装它。
步骤2: 创建一个Git存储库并存储我们希望能够配置限制服务的文件。我们将尝试从spring-cloud-config-server访问它们。打开Git bash并键入以下命令:
创建新目录:
mkdir git-localconfig-repo
cd git-localconfig-repo/

初始化新的Git存储库:
git init

它初始化一个
git存储库。
步骤3: 现在移到
spring-cloud-config-server 项目,然后添加指向特定文件夹的链接。

右键单击 spring-cloud-config-server 项目
点击构建路径-> 配置构建路径
选择来源标签。
点击链接源,然后浏览文件夹 git-localconfig-repo
右键单击文件夹-> 新建-> 其他-> 文件-> 下一步->提供文件名: limits-service-properties -> 完成
现在在属性文件中编写以下代码:

limits-service.minimum=8
limits-service.maximum=888

步骤4: 配置用户名和用户电子邮件:
git config -global user.email abc@example.com
git config -global user.name "abc"

该命令提交使用git add命令添加的任何文件,也提交此后更改的文件。
git add -A

现在执行命令以提交存储库中的更改。它在版本历史记录中永久记录或快照文件。
git commit -m "first commit"

SpringCloud Config Server_https://bianchenghao6.com_【SpringCloud 教程】_第3张

我们可以看到文件是更改了两个新说明。这些说明在本地存储库中已更改。