edit-icon download-icon

Spring Boot Integration

Last Updated: Jul 16, 2018

Health check

Spring Cloud ACM incorporates the Health Check of Spring Boot. Access the health endpoint to see if the Spring Boot application is properly connected to the ACM server:

  1. {
  2. "status": "UP",
  3. "acm": {
  4. "status": "UP",
  5. "dataIds": [
  6. "com.alibaba.cloud.acm:sample-app.properties"
  7. ]
  8. },
  9. "diskSpace": {
  10. "status": "UP",
  11. "total": 1000240963584,
  12. "free": 858827423744,
  13. "threshold": 10485760
  14. },
  15. "refreshScope": {
  16. "status": "UP"
  17. }
  18. }

@RefreshScope

Spring Cloud ACM also supports the Refresh Scope feature of Spring Cloud.

The Bean marked with the annotation @RefreshScope automatically listens for the changes of the ACM server and updates the configuration at run time. Sample code:

  1. @RestController
  2. @RequestMapping("/sample")
  3. @RefreshScope
  4. class SampleController {
  5. @Value("${user.name}")
  6. String userName;
  7. @RequestMapping("/acm")
  8. public String simple() {
  9. return "Hello Spring Cloud ACM!" + " Hello " + userName + "!";
  10. }
  11. }

The Bean marked with the annotation @ConfigurationProperties is subject to Refresh Scope by default.

ACM Endpoint

Spring Cloud ACM has a built-in endpoint named acm, which can be accessed by accessing /acm under the management.port (8080 by default) of Spring Boot applications, for example: http://localhost:8080/acm

  1. {
  2. "runtime": {
  3. "sources": [
  4. {
  5. "dataId": "com.alibaba.cloud.acm:sample-app.properties",
  6. "lastSynced": "2017-10-10 10:46:27"
  7. }
  8. ],
  9. "refreshHistory": [
  10. {
  11. "timestamp": "2017-10-10 10:46:24",
  12. "dataId": "com.alibaba.cloud.acm:sample-app.properties",
  13. "md5": "8692ae986ec7bc345b3f0f4de602ff13"
  14. }
  15. ]
  16. },
  17. "config": {
  18. "group": "DEFAULT_GROUP",
  19. "timeOut": 3000,
  20. "endpoit": "xxx",
  21. "namespace": "xxx",
  22. "accessKey": "xxx",
  23. "secretKey": "xxx"
  24. }
  25. }

Considerations

  • When using Spring Boot 2.x, the ACM Endpoint path is /actuator/acm.
  • When using Spring Boot 2.x, you must add configuration management.endpoints.web.exposure.include=* before you can access ACM Endpoint.
Thank you! We've received your feedback.