我已经创建了使用数据库测试的弹簧引导执行器示例项目。在运行应用程序之后,当我点击URL
`
问题:为什么当我的mongodb没有运行时应用程序状态“下降”。我希望我的应用程序状态“向上”,mongodb是“下降”或“向上”。
下面是我的spring引导应用程序的主要类。
package com.company.testing;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>SpringBootSample</artifactId>
<version>0.0.1</version>
<name>Spring Boot Sample</name>
<description>Spring Boot Sample for spring boot actuator</description>
<groupId>com.company.testing</groupId>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>发布于 2017-01-23 13:36:16
Spring使用HealthIndicatorAutoconfiguration配置各种与健康相关的bean。其中一个bean名为healthAggregator,它使用实现或OrderedHealthAggregator。它将使用所有健康指标中的最低状态来提供总体应用程序状态(这就是为什么您开始使用整个应用程序的原因)。
您可以关闭MongoDb监视(management.health.mongo.enabled=false),也可以编写您自己的AbstractHealthAggregator实现,它将忽略MongoDb关闭,并在您的配置中提供:
@Bean
public MyHealthAggregator healthAggregator() {
return new MyHealthAggregator();
}https://stackoverflow.com/questions/41803253
复制相似问题