1 回答

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超9個(gè)贊
這個(gè)問題在于類的靜態(tài)代碼代碼塊啥時(shí)候執(zhí)行:
在類初始第一個(gè)實(shí)例的時(shí)候或者靜態(tài)方法被使用之類的(或者其他:??具體看Java官方的語(yǔ)言細(xì)究吧)
你這個(gè)才load了class并沒有滿足條件
urls[0] = new URL("file", null, (new File(System.getProperty("user.dir") + File.separator)).toString());
URLClassLoader cl = new URLClassLoader(urls);
Class<?> testee = cl.loadClass("Testee");
Constructor<?> constructor = testee.getConstructor();
Object beanObj = constructor.newInstance();
就可以了
添加回答
舉報(bào)