NutzCN Logo
问答 setup
发布于 3133天前 作者 qq_b4c39298 2135 次浏览 复制 上一个帖子 下一个帖子
标签:

public class MainSetup implements Setup {
static final Logger logger = LoggerFactory.getLogger(MainSetup.class);
public void init(NutConfig nc) {
new DealThread().run();
}

public void destroy(NutConfig nc) {
}

}

public class DealThread implements Runnable {
static final Logger logger = LoggerFactory.getLogger(DealThread.class);
@Inject
private Dao dao;
public void run() {
List lists = dao.query(SmTask.class));
//dao 空指针异常
}
}
大神看看

2 回复

这标题真心想直接封贴.

直接new一个对象,想注入,真是异想天开.

@IocBean
public class DealThread implements Runnable {
     static final Logger logger = LoggerFactory.getLogger(DealThread.class);
     @Inject
     private Dao dao;
     public void run() {
         List lists = dao.query(SmTask.class));
     }
}

public void init(NutConfig nc) {
  nc.getIoc().get(DealThread.class).run();
 }

哦 下次会注意的 谢兽总

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