我设计了一个使用 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/