今天工作中发现一个问题,就是我写Junit时使用对象如果是new出来的话是找不到对象的
公司用的是SSI架构,头儿说我们在Dao层获取语句啊命令啊都是走的Spring,
如Dao的实现层
@Override
public int selectcount(int year) {
//getSqlMapClientTemplate从spring获取
return (Integer)getSqlMapClientTemplate().queryForObject
("testquestion.selectcount", year);
}
那我们在写Junit时,是不应该new对象的,而是应该这么写
@Test
public void test()
{
ITestquestionDao td=(ITestquestionDao)context.getBean
("testquestionDao");
int list=td.selectcount(2010);
System.out.println(list+"**********");
}
不是很明白……