How can I check if my server is UP or DOWN in SpringMVC or just simple in 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.
@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
. If it returns "up", you're OK.
If you use Spring Boot, you can take a look at actuator
. It allows this functionality out of the box plus some other stuff like datasource checking and so on
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.