2016-09-22 234 views
0

我設計了一個帶有MySQL數據庫的演示程序spring boot應用程序CRUD操作。我的application.properties文件如下。Spring引導執行程序MySQL數據庫健康檢查

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 

彈簧執行器的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> 

當我嘗試打網址 「http://localhost:8080/health」,我得到{ 「地位」: 「UP」}如響應。我想用彈簧啓動執行器監視我的數據庫(MySQL)。我想看到我的數據庫狀態。

任何人都可以請幫忙嗎?

+0

你需要數據庫的狀態嗎?是否可以請您解釋更多 –

+0

是的,我需要數據庫狀態,而且我並不十分清楚彈簧啓動時我們可以使用彈簧啓動器執行的最大數據庫細節。 – Harshil

回答

5

我會檢查the documentation - 以匿名形式暴露全部細節需要禁用執行器的安全性。

如果這不是您想要的,您可以完全控制安全性並使用Spring Security編寫自己的規則。

+0

哇。明白了..謝謝你。 – Harshil

1

如果您使用彈簧安全功能,則執行器默認啓用安全功能。

添加這在你的屬性文件 -

management.security.enabled= false 

OR

添加用戶名和密碼在屬性文件 -

security.user.name= username 
security.user.password = password 

,並使用這些憑據訪問驅動器的端點。