在consul中添加配置

在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.然后重启应用,刷新

查看自己的接口是否有输出

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值