如何使用嵌入式 Tomcat 检查 Tomcat 是否正在运行 [英] How to check if Tomcat runnning using Embedded Tomcat
问题描述
参考其中一篇文章:如何嵌入 Tomcat 6?
我了解如何在 Java 应用程序中嵌入 tomcat.感谢那.但是我需要知道 org.apache.catalina.startup.Embedded 是否提供了任何优雅的方法来检查容器是否已经启动?
I understood how to embed tomcat in a java application. Thanks for that. However I need to know if there is any elegant method provided by org.apache.catalina.startup.Embedded to check if the container is already started or not?
例如,如果我为上面链接中给出的示例创建一个批处理文件并单击它两次;第二次它会因 JVM_BIND 错误而失败;tomcat 正在运行.
For example, if I create a batch file for the example given in the link above and click it twice; second time it would fail with JVM_BIND error; tomcat is running.
请帮忙.
推荐答案
您可以使用 Tomcat wiki 上提供的示例代码
You could use the example code given on the Tomcat wiki
http://wiki.apache.org/tomcat/HowTo#How_do_I_check_whether_Tomcat_There_is_UPF_or/a>
http://wiki.apache.org/tomcat/HowTo#How_do_I_check_whether_Tomcat_is_UP_or_DOWN.3F_There_is_no_status_command
注意:这不使用Embedded
它正在尝试连接到 Tomcat ip:port 并查看它是否响应.
It is trying to connect to the Tomcat ip:port and seeing if it responds.
这篇关于如何使用嵌入式 Tomcat 检查 Tomcat 是否正在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!