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:
Modify application.properties:
( 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:
Increase the profile bootstrap.properties:
Modify application.properties:
( 3 ) Starting and testing
In the Boot Dashboard start two services.
Enter the test in the browser:
因为在git库中没有建立目录desktop/config,解决办法参见如下C问题,改为使用远程仓库。
修改远程仓库的a-bootiful-client.properties文件为:
测试结果:
这时需要进一步处理,在client项目中增加依赖:
重新启动client服务,然后在命令行中执行:
如果系统不识curl,则请安装curl工具。
再次测试client:
测试成功。
(4)问题:
A、无法启动client
原因是创建项目时忘记选择web,解决办法是增加对spring-boot-starter-web的依赖,以便启动tomcat:
B、No such label: master
使用master分支,使用其他分支还需要特殊设置
C、Cannot clone or checkout repository: http://localhost:8000/scm/git/config
First, modify the server application.properties:
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."
D、Cannot load environment
G IT status does not, restart the PC