`

There is no DAO implementation found for class问题的解

    博客分类:
  • J2EE
阅读更多
用iBATIS的DAO写了个东西
新增一个表的CRUD实现后,出现了以下的问题:
Exception in thread "main" com.ibatis.dao.client.DaoException: There is no DAO implementation found for class com.ccutsesms.mis.dao.impl.BDM in any context. If you've registered multiple implementations of this DAO, you must specify the Context ID for the DAO implementationyou're looking for using the getDao(Class iface, String contextId) method.
	at com.ibatis.dao.engine.impl.StandardDaoManager.getDao(StandardDaoManager.java:64)
	at com.ccutsesms.mis.service.BDMService.getBDM(BDMService.java:20)
	at com.ccutsesms.mis.util.BDMTag.getTags(BDMTag.java:21)
	at test.com.ccutsesms.mis.util.TestTags.main(TestTags.java:19)


我的实现如下:
DAO Interface:
com.ccutsesms.mis.dao.IBDM;

DAO implement:
com.ccutsesms.mis.dao.impl.BDM;

DAO configure file:
<daoConfig>
    <context>
        <transactionManager type="SQLMAP">
            <property name="SqlMapConfigResource"
                     value="com/ccutsesms/mis/maps/SqlMapConfig.xml"/>
        </transactionManager>
        ... ...
        <dao interface="com.ccutsesms.mis.dao.IBDM"  
        	implementation="com.ccutsesms.mis.dao.impl.BDM"/>
        ... ...
    </context>
</daoConfig>

DAO service:

public class BDMService {
    static DaoManager daoManager = DaoConfig.getDaoManager();
	public List<BDMDto> getBDM(String bdm_type) {
	IBDM bdm = (IBDM) daoManager.getDao(BDM.class);
         ... ...

后来发现是这里写错了
IBDM bdm = (IBDM) daoManager.getDao(BDM.class);

应为
IBDM bdm = (IBDM) daoManager.getDao(IBDM.class);

真是一不小心疏忽了,可能其他人做的时候一样容易疏忽吧。写出来,警记!!!
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics