我正在使用spring boot health。我只是想每次弥补。所以我在下面添加,
@Component
public class AggregationHealth implements HealthIndicator {
@Override
public Health health() {
Health health = Health.up().build();
logger.info("----------------------------Health status : " + health.getStatus() + "----------------------------");
return health;
}
}
日志显示状态Up但是当我使用下面的url访问我的应用程序时,它显示为Down。
http://localhost:8085/health
我还在下面的pom.xml中添加了
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
编辑:
一旦我添加"endpoints.health.sensitive=false"
,它就会出现以下描述性错误,
{
"status": "DOWN",
"aggregationHealth": {
"status": "UP"
},
"diskSpace": {
"status": "UP",
"free": 371498577920,
"threshold": 10485760
},
"mongo": {
"status": "DOWN",
"error": "org.springframework.dao.DataAccessResourceFailureException: Timed out after 10000 ms while waiting to connect. Client view of cluster state is {type=Unknown, servers=[{address=localhost:27017, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused by {java.net.ConnectException: Connection refused: connect}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 10000 ms while waiting to connect. Client view of cluster state is {type=Unknown, servers=[{address=localhost:27017, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused by {java.net.ConnectException: Connection refused: connect}}]"
}
}
所以,自从mongo关闭后,我在application.properties文件中添加了一个mongo db详细信息。但我的问题是,我的服务不需要mongodb。
我甚至也添加了spring.data.mongodb.repositories.enabled=false
。
在这种情况下,如何在不指定mongo详细信息的情况下使健康状态升级?
答案 0 :(得分:4)
您可以删除对Mongo的依赖关系,或者如果您只想禁用MongoDB的Health指示符,请添加以下属性:
management.health.mongo.enabled=false