日期:2014-05-20  浏览次数:20641 次

spring+ibatis下报错:There is no statement named selectSQL in this SqlMap
There is no statement named selectSQL in this SqlMap
代码如下:

beans-ibatis.xml:
<bean id="meatOutInfoBaseDao" class="com.sunraw.kunming.dao.impl.MeatOutInfoBaseDaoImpl">
<property name="sqlMapClient">
<ref local="client" />
</property>
</bean>

<bean name="meatOutInfoBaseService"
class="com.sunraw.kunming.service.impl.MeatOutInfoBaseServiceImpl">
<property name="meatOutInfoBaseDao">
<ref bean="meatOutInfoBaseDao" />
</property>
</bean>

SqlMapConfig.xml:
<sqlMapConfig>
<!--定义iBATIS自身应用信息-->
<settings cacheModelsEnabled="true" enhancementEnabled="true"
lazyLoadingEnabled="true" maxRequests="200" maxSessions="100"
maxTransactions="20" useStatementNamespaces="true" />


<sqlMap resource="User.xml" />
<sqlMap resource="MeatOutInfoBase.xml" />
<sqlMap resource="MeatOutInfoDetail.xml" />
<sqlMap resource="MeatOutInfoSendFail.xml" />
</sqlMapConfig>

MeatOutInfoBase.xml:
<sqlMap namespace="MeatOutInfoBase">

<typeAlias alias="MeatOutInfoBase" type="com.sunraw.kunming.model.MeatOutInfoBase" />

<resultMap id="SelectResult" class="MeatOutInfoBase">
<result property="tranId" column="TRAN_ID" />
<result property="butcherFacId" column="BUTCHER_FAC_ID" />
<result property="butcherFacName" column="BUTCHER_FAC_NAME" />
<result property="transantionDate" column="TRANSANTION_DATE" />
<result property="sellerId" column="SELLER_ID" />
<result property="sellerName" column="SELLER_NAME" />
<result property="buyerId" column="BUYER_ID" />
<result property="buyerName" column="BUYER_NAME" />
<result property="dest" column="DEST" />
<result property="sendState" column="SEND_STATE" />
<result property="sendFailReson" column="SEND_FAIL_RESON" />
</resultMap>

<select id="selectSQL" resultMap="SelectResult">
<![CDATA[
select
TRAN_ID,
BUTCHER_FAC_ID,
BUTCHER_FAC_NAME,
TRANSANTION_DATE,
SELLER_ID,
SELLER_NAME,
BUYER_ID,
BUYER_NAME,
DEST,
SEND_STATE,
SEND_FAIL_RESON
from meat_out_info_base
]]>
</select>
</sqlMap>

dao:
public interface MeatOutInfoBaseDao extends GenericDao<MeatOutInfoBase, String> {

}
dao.impl:
public class MeatOutInfoBaseDaoImpl extends GenericDaoImpl<MeatOutInfoBase, String> implements MeatOutInfoBaseDao {

}
service:
@WebService
public interface MeatOutInfoBaseService extends GenericService<MeatOutInfoBase,String> {
//public boolean Login(String userName, String password);
}
service.impl:
@WebService(endpointInterface = "com.sunraw.kunming.service.MeatOutInfoBaseService")
public class MeatOutInfoBaseServiceImpl extends GenericServiceImpl<MeatOutInfoBase, String> implements MeatOutInfoBaseService {

private MeatOutInfoBaseDao meatOutInfoBaseDao;

public void setMeatOutInfoBaseDao(MeatOutInfoBaseDao meatOutInfoBaseDao) {  
        this.meatOutInfoBaseDao = meatOutInfoBaseDao;  
    }

public GenericDao<MeatOutInfoBase, String> getDao(){
return meatOutInfoBaseDao;
}
}


错误提示:
xception in thread "main" com.ibatis.sqlmap.client.SqlMapException: There is no statement named selectSQL in this SqlMap.
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMappedStatement(SqlMapExecutorDelegate.java:293)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:606)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:589)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
at org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:298)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:209)
at org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:296)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:290)
at com.sunraw.rock.dao.impl.GenericDaoImpl.select(GenericDaoImpl.java:157)
at com.sunraw.test.Tests.TestDao(Tests.java:48)
at com.sunraw.test.Tests.main(Tests.java:19)
上面红色标记处明明有selectSQL,为什么会提示这个错误呢?
------解决方案--------------------
对ibatis不熟悉,和<sqlMap namespace="MeatOutInfoBase">