如何检查应用程序是否在嵌入式 Tomcat 7 上运行? [英] How to check if app is running on Tomcat 7 embedded?

查看:33
本文介绍了如何检查应用程序是否在嵌入式 Tomcat 7 上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序作为 war 或独立模式运行并嵌入了 tomcat,我想检查该应用程序是在 tomcat 中作为 war 运行还是在嵌入 tomcat 的情况下运行.

I have a application that runs as war or in standalone mode with tomcat embedded, I want to check if the application is running as a war within tomcat or if it is running with tomcat embedded.

推荐答案

这是我的解决方案.

String path = getClass().getProtectionDomain().getCodeSource().getLocation().getFile();
boolean onWar = path.contains("WEB-INF");

这篇关于如何检查应用程序是否在嵌入式 Tomcat 7 上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆