@Rekoe 好像不行
单元测试:
public class IocMasterTest {
@Test
public void readProperties(){
PropertiesProxy proxy = IocMaster.getInstance().get(PropertiesProxy.class);
Assert.assertTrue(null != proxy.get("db.driver"));
}
}
报错:
ALL Nutz Log via Log4jLogAdapter
Log4j: 14:57:13 INFO org.nutz.log.Logs [<clinit>] - Nutz is licensed under the Apache License, Version 2.0 .
Report bugs : https://github.com/nutzam/nutz/issues
Log4j: 14:57:13 INFO org.nutz.resource.impl.ErrorResourceLocation [<init>] - ErrorResourceLocation [loc=D:\Document\Work\Hoperun\Main\PRJ-2015-%e5%8d%97%e7%bd%91IMS\SVN-XA\CODE\06-statkpi-engine\nwims-statkpi-engine\target\classes], maybe it is in your classpath, but not exist
Log4j: 14:57:14 DEBUG org.nutz.resource.Scans [<init>] - Locations for Scans:
[JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\jre\lib\ext\sunjce_provider.jar], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\jre\lib\jce.jar], FileSystemResourceLocation [root=D:\Document\Work\Hoperun\Main\PRJ-2015-南网IMS\SVN-XA\CODE\06-statkpi-engine\nwims-statkpi-engine], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\jre\lib\management-agent.jar], JarResourceLocation [jarPath=D:\Lab\bin\maven\.m2\repository\junit\junit\4.11\junit-4.11.jar], JarResourceLocation [jarPath=D:\Lab\bin\maven\.m2\repository\com\alibaba\druid\1.0.14\druid-1.0.14.jar], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\jre\lib\resources.jar], JarResourceLocation [jarPath=D:\Lab\bin\maven\.m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar], JarResourceLocation [jarPath=D:\Lab\bin\maven\.m2\repository\com\oracle\ojdbc6\11.2.0.4.0\ojdbc6-11.2.0.4.0.jar], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\jre\lib\deploy.jar], JarResourceLocation [jarPath=D:\Lab\bin\maven\.m2\repository\org\nutz\nutz\1.b.53\nutz-1.b.53.jar], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\jre\lib\javaws.jar], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\jre\lib\ext\sunmscapi.jar], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\jre\lib\ext\localedata.jar], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\jre\lib\rt.jar], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\jre\lib\ext\dnsns.jar], FileSystemResourceLocation [root=D:\Document\Work\Hoperun\Main\PRJ-2015-南网IMS\SVN-XA\CODE\06-statkpi-engine\nwims-statkpi-engine\target\test-classes], JarResourceLocation [jarPath=D:\Lab\bin\IntelliJ IDEA 14.1.4\plugins\junit\lib\junit-rt.jar], JarResourceLocation [jarPath=D:\Lab\bin\IntelliJ IDEA 14.1.4\lib\idea_rt.jar], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\jre\lib\plugin.jar], FileSystemResourceLocation [root=D:\Document\Work\Hoperun\Main\PRJ-2015-南网IMS\SVN-XA\CODE\06-statkpi-engine\nwims-statkpi-engine\target\classes], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\jre\lib\jsse.jar], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\lib\tools.jar], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\lib\jconsole.jar], JarResourceLocation [jarPath=D:\Lab\bin\Java\jdk1.6.0_45\jre\lib\charsets.jar], ErrorResourceLocation [loc=D:\Document\Work\Hoperun\Main\PRJ-2015-%e5%8d%97%e7%bd%91IMS\SVN-XA\CODE\06-statkpi-engine\nwims-statkpi-engine\target\classes], JarResourceLocation [jarPath=D:\Lab\bin\maven\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar]]
Log4j: 14:57:14 DEBUG org.nutz.resource.Scans [scan] - Found 2 resource by src( etc/ ) , regex( ^(.+[.])(js|json)$ )
Log4j: 14:57:14 DEBUG org.nutz.resource.Scans [scan] - Found 1 resource by src( /etc/ ) , regex( ^(.+[.])(js|json)$ )
Log4j: 14:57:14 DEBUG org.nutz.ioc.loader.json.JsonLoader [<init>] - loading ioc js config from [db.js]
Log4j: 14:57:14 DEBUG org.nutz.ioc.loader.json.JsonLoader [<init>] - Loaded 3 bean define from path=[/etc/] --> [dataSource, dao, config]
Log4j: 14:57:14 DEBUG org.nutz.resource.Scans [scan] - Found 5 resource by src( com/nari/nwims/skengine/ ) , regex( ^.+[.]class$ )
Log4j: 14:57:14 DEBUG org.nutz.ioc.loader.annotation.AnnotationIocLoader [addClass] - Found a Class with Ioc-Annotation : class com.nari.nwims.skengine.glance.LittleBlueBird
Log4j: 14:57:14 DEBUG org.nutz.castor.Castors [reload] - Using 91 castor for Castors
Log4j: 14:57:14 INFO org.nutz.ioc.loader.annotation.AnnotationIocLoader [<init>] - Scan complete ! Found 1 classes in 1 base-packages!
beans = ["littleBlueBird"]
Log4j: 14:57:14 INFO org.nutz.ioc.impl.NutIoc [<init>] - NutIoc init begin ...
Log4j: 14:57:14 INFO org.nutz.ioc.impl.NutIoc [<init>] - ... NutIoc init complete
Log4j: 14:57:14 DEBUG org.nutz.ioc.impl.NutIoc [get] - Get 'propertiesProxy'<class org.nutz.ioc.impl.PropertiesProxy>
Log4j: 14:57:14 DEBUG org.nutz.ioc.impl.NutIoc [get] - >> Load definition
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.readProperties(IocMasterTest.java:16)
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
Process finished with exit code -1