How to check if app is running on Tomcat 7 embedded?

早过忘川 提交于 2020-03-05 04:22:48

问题


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.


回答1:


This is my solution.

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


来源:https://stackoverflow.com/questions/56587068/how-to-check-if-app-is-running-on-tomcat-7-embedded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!