NutzCN Logo
问答 Nutz如何查询数据库内容
发布于 2433天前 作者 qq_fdbf1af8 2144 次浏览 复制 上一个帖子 下一个帖子
标签: dao

public AccountInfo ac(String phone) {
AccountInfo query = dao().fetch(AccountInfo.class, Cnd.where("mobilePhone", "=", phone));
return query;
}
public static void main(String[] args) {
AccountInfoService service = new AccountInfoService();
AccountInfo info = service.ac("123456");
System.out.println(info.getId());

}

怎么我使用以上代码擦村出现的是
Exception in thread "main" java.lang.NullPointerException
at com.forwage.service.AccountInfoService.ac(AccountInfoService.java:29)
at com.forwage.service.AccountInfoService.main(AccountInfoService.java:34)

求解??

1 回复

AccountInfoService要从ioc容器取出来才有"注入"的, 直接new是不行的.

http://nutzam.com/core/ioc/ioc_by_hand.html

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