tomcat类加载器的层次及加载路径

程序代码

URLClassLoader loader = (URLClassLoader) this.getClass().getClassLoader();
while (loader != null) {
    System.out.println(loader.getClass().getName());
    URL[] urls = loader.getURLs();
    for (URL url : urls)
        System.out.println(url);
    System.out.println("----------------------------");

    loader = (URLClassLoader)loader.getParent();
}

System.out.println("BootstrapClassLoader加载路径: ");
URL[] urls = sun.misc.Launcher.getBootstrapClassPath().getURLs();
for (URL url : urls) {
    System.out.println(url);
}

运行结果

org.apache.catalina.loader.WebappClassLoader
项目的加载路径…
org.apache.catalina.loader.StandardClassLoader
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/annotations-api.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/catalina-ant.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/catalina-ha.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/catalina-tribes.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/catalina.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/ecj-4.4.2.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/el-api.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/jasper-el.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/jasper.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/jsp-api.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/servlet-api.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/tomcat-api.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/tomcat-coyote.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/tomcat-dbcp.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/tomcat-i18n-es.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/tomcat-i18n-fr.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/tomcat-i18n-ja.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/tomcat-jdbc.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/tomcat-util.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/tomcat7-websocket.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/lib/websocket-api.jar
sun.misc.Launcher$AppClassLoader
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/bin/bootstrap.jar
file:/C:/Program%20Files%20(x86)/Tomcat/apache-tomcat-7.0.62/bin/tomcat-juli.jar
sun.misc.Launcher$ExtClassLoader
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/ext/access-bridge-32.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/ext/dnsns.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/ext/jaccess.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/ext/localedata.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/ext/sunec.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/ext/sunjce_provider.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/ext/sunmscapi.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/ext/sunpkcs11.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/ext/zipfs.jar
BootstrapClassLoader加载路径:
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/resources.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/rt.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/sunrsasign.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/jsse.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/jce.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/charsets.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/lib/jfr.jar
file:/C:/Program%20Files%20(x86)/Java/jdk1.7.0_79/jre/classes

阅读更多
文章标签: tomcat
个人分类: tomcat
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

tomcat类加载器的层次及加载路径

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭