标签:
CatalinaProperties是加载全局配置
该类有一个Properties properties成员
1 从系统变量中看是否有配置文件,如果有的话加载
private static String getConfigUrl() { return System.getProperty("catalina.config"); }
if (configUrl != null) { is = (new URL(configUrl)).openStream(); }
2.如果系统变量没有配置,查找CatalinaBase()下的conf目录下的catalina.properties,有的话加载
if (is == null) { try { File home = new File(getCatalinaBase()); File conf = new File(home, "conf"); File propsFile = new File(conf, "catalina.properties"); is = new FileInputStream(propsFile); } catch (Throwable t) { handleThrowable(t); } }
3.如果还没有,在/org/apache/catalina/startup下寻找catalina.properties
if (is == null) { try { is = CatalinaProperties.class.getResourceAsStream ("/org/apache/catalina/startup/catalina.properties"); } catch (Throwable t) { handleThrowable(t); } }
按照以上顺序寻找配置文件,如果找到就load
properties = new Properties(); properties.load(is);
Tomcat CatalinaProperties的loadProperties()方法
标签:
原文地址:http://blog.csdn.net/u011686226/article/details/46533999