spring cloud consul注册的服务报错critical的解决

作者:流浪的神明 时间:2021-05-28 14:13:14 

测试spring cloud 使用consul注册服务的时候,出现critical,如下:

spring cloud consul注册的服务报错critical的解决

怎么解决这个问题,现在只能看到health check检查失败了。

受限调用这个请求Get http://consulIp:8500/v1/agent/checks,调完请求,就会拿到返回数据:


{
 ......
 "service:test-service-xx-xx-xx-xx": {
   "Node": "zookeeper-server1",
   "CheckID": "service:test-service-xx-xx-xx-xx",
   "Name": "Service 'test-service' check",
   "Status": "critical",
   "Notes": "",
   "Output": "HTTP GET http://xxx.xx.xxx.xxx:19008/actuator/health: 404 Output: <html><body><h1>Whitelabel Error Page</h1><p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p><div id='created'>Fri Mar 15 11:03:30 CST 2019</div><div>There was an unexpected error (type=Not Found, status=404).</div><div>No message available</div></body></html>",
   "ServiceID": "test-service-xx-xx-xx-xx",
   "ServiceName": "test-service",
   "ServiceTags": [
     "version=1.0",
     "secure=false"
   ],
   "Definition": {},
   "CreateIndex": 0,
   "ModifyIndex": 0
 }

........
}

就能看到consul调用http://xxx.xx.xxx.xxx:19008/actuator/health来检查servoce健康,却发现接口404,所以才会在页面出现错误。

我的测试环境是:

  • spring cloud Finch1ey.SR2

  • consul v1.4.3

bootstrap.yml配置是:


spring:
cloud:
 consul:
  host: xxx.xxx.xxx.xxx
  port: 8500
  discovery:
   prefer-ip-address: true
   tags: version=1.0
   instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}
   healthCheckInterval: 15s
   health-check-url: http://${spring.cloud.client.ip-address}:${server.port}/actuator/health

显然consul不能在这个服务上找到actuator/health接口,因为我用了actuator,所以service中应该配置了spring cloud actuator。

经过检查发现没有配置,所以actuator这个端点不能使用,加上这个包,问题就解决了。

来源:https://segmentfault.com/a/1190000018516277

标签:spring,cloud,consul,注册服务
0
投稿

猜你喜欢

  • Java List转换成String数组几种实现方式详解

    2023-11-10 07:19:41
  • SprintBoot深入浅出讲解场景启动器Starter

    2023-11-24 20:58:58
  • 使用Logback日志保存到相对路径的操作

    2021-10-11 16:42:30
  • Java手写线程池的实现方法

    2023-10-30 12:50:03
  • 深入理解Spring事务原理

    2022-01-18 04:16:39
  • Java实现输出数字三角形实例代码

    2023-08-25 02:09:51
  • 详解Kotlin:forEach也能break和continue

    2022-05-03 01:24:10
  • springboot返回前端中文乱码的解决

    2023-08-09 11:49:12
  • Java关键字详解之final static this super的用法

    2022-01-19 09:24:39
  • 一文详解Java中Stream流的使用

    2021-08-23 11:54:51
  • Java动态显示文件上传进度实现代码

    2022-09-09 20:18:17
  • 替换so文件来动态替换Flutter代码实现详解

    2023-06-23 16:24:06
  • Java简单实现SpringMVC+MyBatis分页插件

    2023-09-09 23:08:45
  • java模拟TCP通信实现客户端上传文件到服务器端

    2023-11-26 10:14:49
  • java自定义ClassLoader加载指定的class文件操作

    2022-03-16 16:19:07
  • SpringBoot整合ES解析搜索返回字段问题

    2023-01-26 21:39:53
  • 浅谈Java三目运算

    2023-11-29 07:27:59
  • Studio 编译报错:compileSdkVersion 'android-24' requires JDK 1.8 or later to compile.的解决办法

    2023-06-19 17:19:41
  • JAVA.io读写文件方式汇总

    2022-10-14 06:32:21
  • springboot ErrorPageFilter的实际应用详解

    2023-11-24 01:02:59
  • asp之家 软件编程 m.aspxhome.com