问题
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