var ioc = {
config : {
type : "org.nutz.ioc.impl.PropertiesProxy",
fields : {
// paths : ["custom/db.properties"]
paths : ["../db.properties"]
}
}
}
1、看日志,config这个类已经进入ioc了
log.debug(Arrays.toString(IocMaster.getInstance().getNames()));
[allBeans] - [txREPEATABLE_READ, txREAD_COMMITTED, txNONE, littleBlueBird, txSERIALIZABLE, config, txREAD_UNCOMMITTED]
2、单元测试时,用has方法是通过的
Assert.assertTrue(IocMaster.getInstance().has("config"));
3、但是用get却get不到。这是为什么?
Assert.assertTrue(null != IocMaster.getInstance().get(PropertiesProxy.class));
org.nutz.ioc.IocException: Object 'propertiesProxy' without define! For object [propertiesProxy] - type:[class org.nutz.ioc.impl.PropertiesProxy]
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:203)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:221)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:140)
at com.nari.nwims.skengine.IocMasterTest.exist2(IocMasterTest.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: org.nutz.ioc.ObjectLoadException: Object 'propertiesProxy' without define!
at org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:149)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:168)
... 29 more
```
```