在控制器 Spring Boot 中调用执行器 [英] Call actuator within controller Spring Boot
问题描述
我正在尝试公开一个内部调用弹簧执行器的自定义端点.但我读超时了;嵌套异常是 java.net.SocketTimeoutException: Read timed out.
I am trying to expose a custom endpoint which internally calls spring actuator. but i am getting Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out.
@GetMapping(value = "/${spring.application.name}/actuator/health")
public ResponseEntity<Object> createUser() {
ResponseEntity<Map> entity = this.restTemplate.getForEntity("http://localhost:" + this.port
+ "/actuator/health", Map.class);
return new ResponseEntity<>(entity, HttpStatus.OK);
}
有什么办法可以让它发挥作用.
Is there any way to make it work.
推荐答案
无需创建自己的端点,只需设置 management.endpoints.web.base-path=${spring.application.name}
在 application.properties
中.请参阅 https:///docs.spring.io/spring-boot/docs/2.1.13.RELEASE/reference/html/production-ready-monitoring.html.
There’s no need to create your own endpoint, just set management.endpoints.web.base-path=${spring.application.name}
in application.properties
. See https://docs.spring.io/spring-boot/docs/2.1.13.RELEASE/reference/html/production-ready-monitoring.html.
这篇关于在控制器 Spring Boot 中调用执行器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!