在consul中添加配置
一、下载consul
这里就不细说了
二、运行consul
consul agent -dev
三、运行成功自己的服务
查看服务是否注册到consul上
如果consul服务check爆红,请看我另一篇文章
如果没注册成功检查自己的application配置文件以及依赖是否都有或者有问题
比如consul-config、consul-discovery之类的
下面是我的配置文件,我刚开始学,可能有些不完整,但是初学够用了,都是运行成功了的,但是仅供参考
spring: config: import: "consul:" application: name: ca-service cloud: consul: config: prefix: config default-context: application profile-separator: "," profiles: active: dev custom: socket: port: 5000 server: port: 8999 management: endpoints: web: exposure: include: refresh,info, health, configprops
四、创建配置文件
推荐:
(单独的 Key):(√)
Key: config/ca-service,dev/example/hello
Value: `hello from consul dev!
1.
2.创建
config/ca-service,dev/example/hello
文件夹/服务名称,(英文)环境/要打印的(我这里就是创建example.hello要打印hello world!验证我的项目consul是否正常,能否修改)
3.然后重启应用,刷新
查看自己的接口是否有输出