4 回答

TA贡献1804条经验 获得超3个赞
getResource("") 返回的当然是null了
获取classpath的值使用
System.getProperty(“java.class.path”);

TA贡献1785条经验 获得超4个赞
你可以尝试下面这种方式: 不知道是不是你想要的. 全部放入系统加载器里面.
ClassLoader classLoader=ClassLoader.getSystemClassLoader();
Thread thread0=new Thread();
thread0.currentThread().setContextClassLoader(classLoader);
Thread thread1=new Thread();
thread1.currentThread().setContextClassLoader(classLoader);
Thread thread2=new Thread();
thread2.currentThread().setContextClassLoader(classLoader);
System.out.println(thread0.getContextClassLoader());
System.out.println(thread1.getContextClassLoader());
System.out.println(thread2.getContextClassLoader());
- 4 回答
- 0 关注
- 481 浏览
添加回答
举报