亲自动手搭建微服务框架和测试环境-10-配置中心

1实例

1)建立服务器git

使用FileàNewàSpring Starter Project建立项目,按照向导选择config serverweb

使用注解@EnableConfigServer,以下:spring

image.png


修改application.properties:bootstrap

image.png

2)建立客户端浏览器

使用FileàNewàSpring Starter Project建立项目,按照向导选择config serverwebtomcat

建立控制器类,增长注解,以下:服务器

image.png


增长配置文件bootstrap.properties:app

image.png

修改application.properties:curl

image.png

3)启动和测试ide

Boot Dashboard中启动两个服务。

在浏览器中输入测试:

image.png

由于在git库中没有创建目录desktop/config,解决办法参见以下C问题,改成使用远程仓库。

 

修改远程仓库的a-bootiful-client.properties文件为:

image.png

测试结果:

image.png


image.png


这时须要进一步处理,在client项目中增长依赖:

image.png


从新启动client服务,而后在命令行中执行:

image.png


若是系统不识curl,则请安装curl工具。

再次测试client

image.png


测试成功。


4)问题:

A、没法启动client

image.png


缘由是建立项目时忘记选择web,解决办法是增长对spring-boot-starter-web的依赖,以便启动tomcat

image.png


BNo such label: master

使用master分支,使用其余分支还须要特殊设置

CCannot clone or checkout repository: http://localhost:8000/scm/git/config

首先,修改服务器的application.properties:

image.png


而后,在本地master分支根目录下存放a-bootiful-client.properties文件。

最后,把master远程上传到git服务器,指令参见“3.14.3同步文件到远程仓库”。


DCannot load environment

Git状态不对,重启PC

相关文章
相关标签/搜索