4 回答

TA貢獻1790條經驗 獲得超9個贊
getResource("") 返回的當然是null了
獲取classpath的值使用
System.getProperty(“java.class.path”);

TA貢獻1829條經驗 獲得超7個贊
你可以嘗試下面這種方式: 不知道是不是你想要的. 全部放入系統加載器里面.
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 關注
- 828 瀏覽
添加回答
舉報