Hands to build micro-services framework and test environments -10- Configuration Center

1 Examples

( 1 ) Create a server

Use File à New à the Spring Starter Project to create a project, follow the wizard to select config Server .

Use annotations @EnableConfigServer , as follows:

image.png


Modify application.properties:

image.png

( 2 ) create client

Use File à New à the Spring Starter Project to create a project, follow the wizard to select config Server , Web .

Create a controller class, an increase of notes, as follows:

image.png


Increase the profile bootstrap.properties:

image.png

Modify application.properties:

image.png

( 3 ) Starting and testing

In the Boot Dashboard start two services.

Enter the test in the browser:

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

First, modify the server application.properties:

image.png


Then, the local master store branch under the root directory a-bootiful-client.properties file.

Finally, the master remote upload to git server, instruction see " 3.14.3 synchronize files to a remote repository."


DCannot load environment

G IT status does not, restart the PC


Guess you like

Origin blog.51cto.com/5526964/2426402