NutzCN Logo
问答 nutzwk中写测试类用dao的时候报错了
发布于 2431天前 作者 zp8821138 1610 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

代码如下

	try {
			ioc = new NutIoc(new ComboIocLoader("*json", "config/ioc/"));
			Dao  dao = ioc.get(Dao.class);
			int i = dao.count(User.class);
			System.out.println(i);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

错误如下

Exception in thread "main" org.nutz.dao.DaoException: java.lang.NullPointerException
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:140)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:93)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:82)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:252)
	at org.nutz.dao.impl.NutDao.func(NutDao.java:761)
	at org.nutz.dao.impl.NutDao.func(NutDao.java:742)
	at org.nutz.dao.impl.NutDao._count(NutDao.java:729)
	at org.nutz.dao.impl.NutDao.count(NutDao.java:692)
	at com.kanq.test.Test.main(Test.java:71)
Caused by: java.lang.NullPointerException
	at org.nutz.plugins.cache.dao.impl.provider.EhcacheDaoCacheProvider.getCache(EhcacheDaoCacheProvider.java:44)
	at org.nutz.plugins.cache.dao.impl.provider.EhcacheDaoCacheProvider.get(EhcacheDaoCacheProvider.java:21)
	at org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:160)
	at org.nutz.plugins.cache.dao.DaoCacheInterceptor.filter(DaoCacheInterceptor.java:18)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:159)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:126)
	... 9 more

另外测试的时候这样写ioc = new NutIoc(new ComboIocLoader("*json", "config/ioc/"));是否妥当 更标准的写法是啥?

1 回复

nutzmore里面有nutz-plugins-mock哦, nutz文档里面也有介绍

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