亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請教一下關于java :load(Thread.currentThread())?

請教一下關于java :load(Thread.currentThread())?

DIEA 2019-10-21 17:13:56
java :load(Thread.currentThread().getContextClassLoader().getResourceAsStream("db.properties"))
查看完整描述

4 回答

?
富國滬深

TA貢獻1790條經驗 獲得超9個贊

getResource("") 返回的當然是null了
獲取classpath的值使用
System.getProperty(“java.class.path”);

查看完整回答
反對 回復 2019-10-26
?
吃雞游戲

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());

查看完整回答
反對 回復 2019-10-26
  • 4 回答
  • 0 關注
  • 828 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號