java - Spring Boot 执行器 MySQL 数据库健康检查

标签 java mysql spring spring-boot spring-boot-actuator

我设计了一个使用 MySQL 数据库的演示 spring boot 应用程序 CRUD 操作。我的 application.properties 文件如下。

spring.boot.admin.url=http://localhost:8081
spring.datasource.url= jdbc:mysql://localhost:3306/springbootdb
spring.datasource.username=root
spring.datasource.password=admin
endpoints.health.sensitive=false
management.health.db.enabled=true
management.health.defaults.enabled=true
management.health.diskspace.enabled=true
spring.jpa.hibernate.ddl-auto=create-drop

Spring 执行器的POM.xml如下。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-starter-client</artifactId>
    <version>1.3.4</version>
</dependency>

当我尝试点击 url“http://localhost:8080/health”时,我收到 {"status":"UP"} 作为响应。我想用 spring boot actuator 监控我的数据库(MySQL)。我想查看我的数据库状态。

有人可以帮忙吗?

最佳答案

我会检查 the documentation - 匿名公开全部细节需要禁用执行器的安全性。

如果这不是您想要的,您可以完全控制安全性并使用 Spring Security 编写您自己的规则。

关于java - Spring Boot 执行器 MySQL 数据库健康检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39631355/

相关文章:

java - Spring MVC 3.2.8 : Create a new FileSystemXmlApplicationContext and loading the definitions from the given XML files

java - Spring 3的最小Hibernate 4 XML配置,用于基于注释的事务管理和对象映射?

java - POI中如何判断文件是doc还是docx

php - Laravel:+100 表......是否使用迁移?

spring - 我应该使用 Spring Session Scoped beans 还是诸如 ehcache 之类的缓存?

mysql - 如何在一个表的单列和第二个表的多行之间创建关系?

PHP上传图片到文件夹并插入记录到数据库

java - 如何为 "virtual files"列表创建 ZIP 文件并输出到 httpservletresponse

java - fragment 中未解析的类 '@string/appbar_scrolling_view_behavior' 导致未触发行为 OnCreate

java - 向用户发出警报日期和时间存储在数据库中的 TO-DO 任务的警报