[英]SpringMVC check server is UP or DOWN
How can I check if my server is UP or DOWN in SpringMVC or just simple in JAVA? 如何检查我的服务器在SpringMVC中是UP还是DOWN,还是在JAVA中只是简单? I want a simple function how receiving a URL as a parameter and return just one boolean variable TRUE or FALSE which represents a SERVER. 我想要一个简单的函数,该函数如何接收URL作为参数并仅返回一个代表SERVER的布尔变量TRUE或FALSE。
@RestController
public class HealthCheckController {
@RequestMapping("/healthcheck")
public Greeting greeting() {
return "up";
}
}
When you have to check if the server is up just send get request to /healthcheck
. 当您必须检查服务器是否启动时,只需将get请求发送到/healthcheck
。 If it returns "up", you're OK. 如果返回“ up”,就可以了。
If you use Spring Boot, you can take a look at actuator
. 如果您使用Spring Boot,则可以看一下actuator
。 It allows this functionality out of the box plus some other stuff like datasource checking and so on 它允许立即使用此功能以及其他一些东西,例如数据源检查等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.