spring cloud consul注冊(cè)的服務(wù)報(bào)錯(cuò)critical的解決
測(cè)試spring cloud 使用consul注冊(cè)服務(wù)的時(shí)候,出現(xiàn)critical,如下:

怎么解決這個(gè)問(wèn)題,現(xiàn)在只能看到health check檢查失敗了。
受限調(diào)用這個(gè)請(qǐng)求Get http://consulIp:8500/v1/agent/checks,調(diào)完請(qǐng)求,就會(huì)拿到返回?cái)?shù)據(jù):
{
......
"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調(diào)用http://xxx.xx.xxx.xxx:19008/actuator/health來(lái)檢查servoce健康,卻發(fā)現(xiàn)接口404,所以才會(huì)在頁(yè)面出現(xiàn)錯(cuò)誤。
我的測(cè)試環(huán)境是:
- 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不能在這個(gè)服務(wù)上找到actuator/health接口,因?yàn)槲矣昧薬ctuator,所以service中應(yīng)該配置了spring cloud actuator。
經(jīng)過(guò)檢查發(fā)現(xiàn)沒(méi)有配置,所以actuator這個(gè)端點(diǎn)不能使用,加上這個(gè)包,問(wèn)題就解決了。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Java 字符串轉(zhuǎn)float運(yùn)算 float轉(zhuǎn)字符串的方法
今天小編就為大家分享一篇Java 字符串轉(zhuǎn)float運(yùn)算 float轉(zhuǎn)字符串的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-07-07
Spring MVC 中攔截器的使用示例詳解"攔截器基本配置"和 &q
Spring MVC 的攔截器作用是在請(qǐng)求到達(dá)控制器之前或之后進(jìn)行攔截,可以對(duì)請(qǐng)求和響應(yīng)進(jìn)行一些特定的處理,這篇文章主要介紹了Spring MVC 中的攔截器的使用“攔截器基本配置” 和 “攔截器高級(jí)配置”,需要的朋友可以參考下2024-07-07
利用MyBatis-Plus靈活處理JSON字段的技巧與最佳實(shí)踐
這篇文章主要給大家介紹了關(guān)于利用MyBatis-Plus靈活處理JSON字段的技巧與最佳實(shí)踐,Mybatis-Plus可以很方便地處理JSON字段,在實(shí)體類中可以使用@JSONField注解來(lái)標(biāo)記JSON字段,需要的朋友可以參考下2024-07-07
java使用ArrayList實(shí)現(xiàn)斗地主(無(wú)序版)
這篇文章主要為大家詳細(xì)介紹了java使用ArrayList實(shí)現(xiàn)斗地主,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-03-03

