ibatis获取数据问题
bulletinDao.xml
- XML code
<sqlMap namespace="bulletin"> <!-- 获取公告 --> <typeAlias alias="bulletinVo" type="com.gzedu.portal.vo.BulletinVo"/> <resultMap id="bulletinResult" class="bulletinVo"> <result property="id" column="ID"/> <result property="title" column="TITLE"/> <result property="content" column="CONTENT" jdbcType="CLOB" javaType= "java.lang.String" /> <result property="bulType" column="BUL_TYPE"/> <result property="author" column="AUTHOR"/> <result property="origin" column="ORIGIN"/> <result property="createDate" column="CREATED_DT"/> </resultMap> <select id="getBulletin" resultClass="bulletinResult"> select ID,BUL_TYPE ,TITLE,CONTENT,AUTHOR,ORIGIN,to_char(CREATED_DT,'YYYY-MM-DD')as CREATED_DT from xl_bulletin where BUL_STATUS='1' and IS_DELETED='N' and SYSDATE BETWEEN START_DT AND END_DT </select> </sqlMap>
调用这个老是报错如下:
Caused by: com.ibatis.sqlmap.client.SqlMapException: Error. Could not initialize class. Cause: java.lang.ClassNotFoundException: bulletinResult
这个路径type="com.gzedu.portal.vo.BulletinVo"/>
绝肯定是对的,我都直接复制类的package
sqlMap-config.xml那里也有bulletinDao.xml
[解决办法]
java.lang.ClassNotFoundException: bulletinResult
没找到JAR。
[解决办法]
<select id="getBulletin" resultClass="bulletinResult">
改为
<select id="getBulletin" resultMap="bulletinResult">
ibatis中resultClass和resultMap是有区别的,文档还是要看的