NutzCN Logo
问答 关于IocBean Dao注入的问题
发布于 2675天前 作者 文涛(wentao) 2927 次浏览 复制 上一个帖子 下一个帖子
标签:

请问在不开启web服务的情况下,有没有办法在
public static void main函数 或者 @Test注释,将Dao对象注入后使用呢
因为自己做些东西,只需要临时使用,但又希望用到Ioc的便捷方式

20 回复

文档没写nutz-plugins-mock这个插件怎么引用

public class NutTest extends NutTestRunner {
    public NutTest(Class<?> klass) throws InitializationError {
        super(klass);
    }

    protected Ioc createIoc() {
        return new NutIoc(new JsonLoader("*.js", "ioc/", "*jedis"));
    }
}
@RunWith(NutTest.class)
@IocBean
public class xuding {
    @Inject(value = "dao_dianxin_yfb") protected Dao dao;

    @Test
    public void test() {
        assertNotNull(dao);
    }
}

这样测试报错

org.nutz.ioc.IocException: [xuding] # For object [xuding] - type:[class tools.xuding]

	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:218)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:146)
	at org.nutz.mock.NutTestRunner.createTest(NutTestRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:33)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:14)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.nutz.ioc.ObjectLoadException: Object 'xuding' without define!
	at org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:174)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:180)
	... 20 more
return new NutIoc(new JsonLoader("*js", "ioc/", "*jedis", "*anno", "你的package"));

另外,是*js,没有点的

按照你的写法

return new NutIoc(new JsonLoader("*js", "*anno", "tools", "ioc/", "*jedis"));

现在报错:

org.nutz.json.JsonException: !Json syntax error nearby [row:1,col:1 char 'N'], reason: 'Unexpect String = NutTest.class
test
'

	at org.nutz.json.impl.JsonTokenScan.readObject(JsonCompileImplV2.java:297)
	at org.nutz.json.impl.JsonTokenScan.read(JsonCompileImplV2.java:354)
	at org.nutz.json.impl.JsonCompileImplV2.parse(JsonCompileImplV2.java:26)
	at org.nutz.json.Json.fromJson(Json.java:42)
	at org.nutz.json.Json.fromJson(Json.java:144)
	at org.nutz.ioc.loader.json.JsonLoader.loadFromReader(JsonLoader.java:62)
	at org.nutz.ioc.loader.json.JsonLoader.<init>(JsonLoader.java:49)
	at tools.NutTest.createIoc(NutTest.java:20)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:30)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:14)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

改顺序干啥。。。

米号开头的是类名或缩写,后面是参数,顺序错了就完蛋啦

return new NutIoc(new JsonLoader("*js", "ioc/", "*jedis", "*anno", "tools"));

按照你这个新的,还是同样的异常

org.nutz.json.JsonException: !Json syntax error nearby [row:1,col:1 char 'N'], reason: 'Unexpect String = NutTest.class xuding.class '

org.nutz.json.JsonException: !Json syntax error nearby [row:1,col:1 char 'N'], reason: 'Unexpect String = NutTest.class
xuding.class
'

贴你现在的代码

public class NutTest extends NutTestRunner {
    public NutTest(Class<?> klass) throws InitializationError {
        super(klass);
    }

    @Override
    protected Ioc createIoc() {
        return new NutIoc(new JsonLoader("*js", "ioc/", "*jedis", "*anno", "tools"));
    }
}
@RunWith(NutTest.class)
@IocBean
public class xuding {
    @Inject(value = "dao_dianxin_yfb") protected Dao dao;

    @Test
    public void test() {
        System.out.println(dao);
    }
}

是不是没编译好?贴后台日志看看,完整的

/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=51130:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-rt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/htmlconverter.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/javafx-doclet.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/tools.jar:/Users/swt/Documents/办公/wentao_deploy/target/classes:/Users/swt/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/Users/swt/.m2/repository/junit/junit/4.12/junit-4.12.jar:/Users/swt/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/Users/swt/.m2/repository/org/nutz/nutz/1.r.60/nutz-1.r.60.jar:/Users/swt/.m2/repository/org/nutz/nutz-integration-jedis/1.r.60/nutz-integration-jedis-1.r.60.jar:/Users/swt/.m2/repository/redis/clients/jedis/2.9.0/jedis-2.9.0.jar:/Users/swt/.m2/repository/org/apache/commons/commons-pool2/2.4.2/commons-pool2-2.4.2.jar:/Users/swt/.m2/repository/org/nutz/nutz-plugins-mock/1.r.60/nutz-plugins-mock-1.r.60.jar:/Users/swt/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar:/Users/swt/.m2/repository/mysql/mysql-connector-java/5.1.40/mysql-connector-java-5.1.40.jar:/Users/swt/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:/Users/swt/.m2/repository/com/alibaba/druid/1.0.27/druid-1.0.27.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 tools.xuding,test
objc[83775]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java (0x10e1d54c0) and /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10e3644e0). One of the two will be used. Which one is undefined.
[INFO ] 00:51:37.972 - [loc=/Users/swt/Documents/%e5%8a%9e%e5%85%ac/wentao_deploy/target/classes]not exist
[INFO ] 00:51:40.046 - [loc=/Users/swt/Documents/%e5%8a%9e%e5%85%ac/wentao_deploy/target/classes/tools]not exist

org.nutz.json.JsonException: !Json syntax error nearby [row:1,col:1 char 'N'], reason: 'Unexpect String = NutTest.class
xuding.class
'

	at org.nutz.json.impl.JsonTokenScan.readObject(JsonCompileImplV2.java:297)
	at org.nutz.json.impl.JsonTokenScan.read(JsonCompileImplV2.java:354)
	at org.nutz.json.impl.JsonCompileImplV2.parse(JsonCompileImplV2.java:26)
	at org.nutz.json.Json.fromJson(Json.java:42)
	at org.nutz.json.Json.fromJson(Json.java:144)
	at org.nutz.ioc.loader.json.JsonLoader.loadFromReader(JsonLoader.java:62)
	at org.nutz.ioc.loader.json.JsonLoader.<init>(JsonLoader.java:49)
	at tools.NutTest.createIoc(NutTest.java:22)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:30)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:14)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)


Test ignored.

Process finished with exit code 255

日志改成debug级别

/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=64329:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-rt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/htmlconverter.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/javafx-doclet.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/tools.jar:/Users/swt/Documents/办公/wentao_deploy/target/classes:/Users/swt/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/Users/swt/.m2/repository/junit/junit/4.12/junit-4.12.jar:/Users/swt/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/Users/swt/.m2/repository/org/nutz/nutz/1.r.60/nutz-1.r.60.jar:/Users/swt/.m2/repository/org/nutz/nutz-integration-jedis/1.r.60/nutz-integration-jedis-1.r.60.jar:/Users/swt/.m2/repository/redis/clients/jedis/2.9.0/jedis-2.9.0.jar:/Users/swt/.m2/repository/org/apache/commons/commons-pool2/2.4.2/commons-pool2-2.4.2.jar:/Users/swt/.m2/repository/org/nutz/nutz-plugins-mock/1.r.60/nutz-plugins-mock-1.r.60.jar:/Users/swt/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar:/Users/swt/.m2/repository/mysql/mysql-connector-java/5.1.40/mysql-connector-java-5.1.40.jar:/Users/swt/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar:/Users/swt/.m2/repository/com/alibaba/druid/1.0.27/druid-1.0.27.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 tools.xuding,test
objc[84849]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java (0x101e654c0) and /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x101ff44e0). One of the two will be used. Which one is undefined.
[INFO ] 00:55:02.889 - [loc=/Users/swt/Documents/%e5%8a%9e%e5%85%ac/wentao_deploy/target/classes]not exist
[DEBUG] 00:55:05.048 - Locations for Scans:
[Dir[path=/Users/swt/Documents/办公/wentao_deploy], Jar[path=/Users/swt/.m2/repository/org/nutz/nutz/1.r.60/nutz-1.r.60.jar], ErrorResourceLocation [loc=/Users/swt/Documents/%e5%8a%9e%e5%85%ac/wentao_deploy/target/classes], Jar[path=/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar], Jar[path=/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-rt.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/charsets.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/deploy.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/dnsns.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/localedata.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/sunec.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext/zipfs.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/htmlconverter.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/javaws.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jce.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jfr.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jfxrt.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/jsse.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/management-agent.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/plugin.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/resources.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/rt.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/ant-javafx.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/dt.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/javafx-doclet.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/javafx-mx.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/jconsole.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/sa-jdi.jar], Jar[path=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/lib/tools.jar], Dir[path=/Users/swt/Documents/办公/wentao_deploy/target/classes], Jar[path=/Users/swt/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar], Jar[path=/Users/swt/.m2/repository/junit/junit/4.12/junit-4.12.jar], Jar[path=/Users/swt/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar], Jar[path=/Users/swt/.m2/repository/org/nutz/nutz-integration-jedis/1.r.60/nutz-integration-jedis-1.r.60.jar], Jar[path=/Users/swt/.m2/repository/redis/clients/jedis/2.9.0/jedis-2.9.0.jar], Jar[path=/Users/swt/.m2/repository/org/apache/commons/commons-pool2/2.4.2/commons-pool2-2.4.2.jar], Jar[path=/Users/swt/.m2/repository/org/nutz/nutz-plugins-mock/1.r.60/nutz-plugins-mock-1.r.60.jar], Jar[path=/Users/swt/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar], Jar[path=/Users/swt/.m2/repository/mysql/mysql-connector-java/5.1.40/mysql-connector-java-5.1.40.jar], Jar[path=/Users/swt/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar], Jar[path=/Users/swt/.m2/repository/com/alibaba/druid/1.0.27/druid-1.0.27.jar]]
[DEBUG] 00:55:05.086 - Found 0 resource by src( *js ) , regex( ^(.+[.])(js|json)$ )
[DEBUG] 00:55:05.140 - Found 2 resource by src( ioc/ ) , regex( ^(.+[.])(js|json)$ )
[DEBUG] 00:55:05.152 - Found 0 resource by src( *jedis ) , regex( ^(.+[.])(js|json)$ )
[DEBUG] 00:55:05.168 - Found 0 resource by src( *anno ) , regex( ^(.+[.])(js|json)$ )
[INFO ] 00:55:05.180 - [loc=/Users/swt/Documents/%e5%8a%9e%e5%85%ac/wentao_deploy/target/classes/tools]not exist
[DEBUG] 00:55:05.327 - Found 1 resource by src( tools ) , regex( ^(.+[.])(js|json)$ )
[DEBUG] 00:55:05.327 - loading ioc js config from [dao.js]
[DEBUG] 00:55:05.427 - Using 95 castor for Castors
[DEBUG] 00:55:05.437 - loading ioc js config from [jedis.js]
[DEBUG] 00:55:05.440 - loading ioc js config from [tools]

org.nutz.json.JsonException: !Json syntax error nearby [row:1,col:1 char 'N'], reason: 'Unexpect String = NutTest.class
xuding.class
'

	at org.nutz.json.impl.JsonTokenScan.readObject(JsonCompileImplV2.java:297)
	at org.nutz.json.impl.JsonTokenScan.read(JsonCompileImplV2.java:354)
	at org.nutz.json.impl.JsonCompileImplV2.parse(JsonCompileImplV2.java:26)
	at org.nutz.json.Json.fromJson(Json.java:42)
	at org.nutz.json.Json.fromJson(Json.java:144)
	at org.nutz.ioc.loader.json.JsonLoader.loadFromReader(JsonLoader.java:62)
	at org.nutz.ioc.loader.json.JsonLoader.<init>(JsonLoader.java:49)
	at tools.NutTest.createIoc(NutTest.java:22)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:30)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:14)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)


Test ignored.

Process finished with exit code 255

感觉我这种是不是不能用JsonLoader

终于看出来了。。。 你填的是JsonLoader...

应该这样

new NutIoc(new ComboIocLoader("*js", "ioc/", "*jedis", "*anno", "tools"));

嗯,是的,可以了,谢谢!

添加回复
请先登陆
回到顶部