网关服务gateway注册Consul时报错Consul service ids must not be empty

news/2024/7/27 17:48:17

网关服务gateway启动时,初始化Consul相关配置时报错。

Consul service ids must not be empty, must start with a letter, end with a letter or digit, and have as interior characters only letters, digits, and hyphen: cbda-server-gateway:10.111.236.142:30857

详细的错误信息如下:

网关gateway的 bootstrap.yml如下:

spring:main:allow-bean-definition-overriding: trueapplication:name: cbda-server-gatewaycloud:consul:host: 10.111.236.142port: 8500config:enabled: true #false禁用Consul配置,默认trueformat: YAML    # 表示consul上面文件的格式 有四种 YAML PROPERTIES KEY-VALUE FILESdata-key: data   #表示consul上面的KEY值(或者说文件的名字) 默认是dataprefix: config # 设置配置值的基本文件夹defaultContext: cbda-server-gateway # 设置所有应用程序使用的文件夹名称#profileSeparator # 设置用于使用配置文件在属性源中分隔配置文件名称的分隔符的值# 服务发现配置discovery:# 启用服务发现enabled: true# 启用服务注册register: true# 服务停止时取消注册deregister: true# 表示注册时使用IP而不是hostnameprefer-ip-address: true# 关闭consul健康监测register-health-check: true# 执行监控检查的频率health-check-interval: 30s# 设置健康检查失败多长时间后,取消注册health-check-critical-timeout: 30s# 健康检查的路径health-check-path: /soa_actuator/health# 服务注册标识,格式为:应用名称+服务器IP+端口instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${server.port}

分析:

网关服务gateway在初始化Consul的相关配置时,未读取到ip,导致相关配置类初始化失败,就未能初始化instance-id。修改配置如下:

spring:main:allow-bean-definition-overriding: trueapplication:name: cbda-server-gatewaycloud:consul:host: 10.111.236.142port: 8500config:enabled: true #false禁用Consul配置,默认trueformat: YAML    # 表示consul上面文件的格式 有四种 YAML PROPERTIES KEY-VALUE FILESdata-key: data   #表示consul上面的KEY值(或者说文件的名字) 默认是dataprefix: config # 设置配置值的基本文件夹defaultContext: cbda-server-gateway # 设置所有应用程序使用的文件夹名称#profileSeparator # 设置用于使用配置文件在属性源中分隔配置文件名称的分隔符的值# 服务发现配置discovery:# 启用服务发现enabled: true# 启用服务注册register: true# 服务停止时取消注册deregister: true# 表示注册时使用IP而不是hostnameprefer-ip-address: true# 关闭consul健康监测register-health-check: true# 执行监控检查的频率health-check-interval: 30s# 设置健康检查失败多长时间后,取消注册health-check-critical-timeout: 30s# 健康检查的路径health-check-path: /soa_actuator/health# 服务注册标识,格式为:应用名称+服务器IP+端口#instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${server.port}instance-id: ${spring.application.name}:${random.value}

最终服务能正常启动。

参考:The Spring Cloud project throws exception when generating document. · Issue #404 · spring-cloud/spring-cloud-consul · GitHub

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.cpky.cn/p/8657.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

【机器学习基础】一元线性回归(适合初学者的保姆级文章)

🚀个人主页:为梦而生~ 关注我一起学习吧! 💡专栏:机器学习 欢迎订阅!后面的内容会越来越有意思~ 💡往期推荐: 【机器学习基础】机器学习入门(1) 【机器学习基…

【Python笔记-设计模式】装饰器模式

一、说明 装饰器模式是一种结构型设计模式,旨在动态的给一个对象添加额外的职责。 (一) 解决问题 不改变原有对象结构的情况下,动态地给对象添加新的功能或职责,实现透明地对对象进行功能的扩展。 (二) 使用场景 如果用继承来扩展对象行…

07 MyBatis之高级映射 + 懒加载(延迟加载)+缓存

1. 高级映射 例如有两张表, 分别为班级表和学生表 自然, 一个班级对应多个学生 像这种数据 , 应该如果如何映射到Java的实体类上呢? 这就是高级映射解决的问题 以班级和学生为例子 , 因为一个班级对应多个学生 , 因此学生表中必定有一个班级编号字段cid 但我们在学生的实体…

【风格迁移】CAST:对比学习,从图像特征而非其二阶统计量(Gram矩阵)中学习风格

CAST:对比学习,从图像特征而非其二阶统计量(Gram矩阵)中学习风格 提出背景5 why 分析5 so分析 CAST 框架多层风格投影器领域增强模块生成网络 效果对比 StyleGAN 提出背景 论文:https://arxiv.org/pdf/2205.09542.pdf…

Clickhouse的安装

1.准备工作 确定防火墙处于关闭状态 ulimit -a 2.CentOS取消打开文件数限制 (1)在 hadoop102 的 /etc/security/limits.conf 文件的末尾加入以下内容 sudo vim /etc/security/limits.conf * soft nofile 65536 * hard nofile 65536 * soft nproc …

Sora - 探索AI视频模型的无限可能

随着人工智能技术的飞速发展,AI视频模型已成为科技领域的新热点。而在这个浪潮中,OpenAI推出的首个AI视频模型Sora,以其卓越的性能和前瞻性的技术,引领着AI视频领域的创新发展。让我们将一起探讨Sora的技术特点、应用场景以及对未…