java.lang.IllegalArgumentException: No SqlMapClient specified
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:166)
at org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:296)
at com.raycloud.dao.impl.ItemCheckTaskDaoImpl.queryItemCheckTask(ItemCheckTaskDaoImpl.java:66)
at com.raycloud.thread.ItemCheckThread.run(ItemCheckThread.java:57)
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:166)
at org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:296)
at com.raycloud.dao.impl.ItemCheckTaskDaoImpl.queryItemCheckTask(ItemCheckTaskDaoImpl.java:66)
at com.raycloud.thread.ItemCheckThread.run(ItemCheckThread.java:57)
at java.lang.Thread.run(Thread.java:619)
在做spring + ibatis整合时,容易报此类异常
原因是在创建DAO对象时使用了 new xxxDaoImpl()的方法,应该用使用
WebApplicationContext beanFactory = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
ItemCheckTaskDao itemCheckTaskDao = (ItemCheckTaskDao) beanFactory.getBean("itemCheckTaskDao");