昨天自己搭SSM框架,运行的时候总是报下面这一系列的错
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'BaseResultMap'. Cause: java.lang.ClassNotFoundException: Cannot find class: BaseResultMap
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:109)
at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:115)
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:92)
... 80 more
Caused by: java.lang.ClassNotFoundException: Cannot find class: BaseResultMap
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:188)
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:87)
at org.apache.ibatis.io.Resources.classForName(Resources.java:250)
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:105)
... 81 more
自己整了很久,发现是resultMap导致的。
我的XML配置文件如下
<resultMap id="BaseResultMap" type="com.qcbylearn.entitys.testClass" >
<result column="book_id" property="book_id" jdbcType="BIGINT" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="number" property="number" jdbcType="BIGINT" />
</resultMap>
<select id="getAllBook" resultType="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Book_Column_List" />
from book
</select>
上下的resultMap要对应,而我在select中写的是resultType。
只要select中的resultType改为resultMap之后就不再报错。
即
<select id="getAllBook" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Book_Column_List" />
from book
</select>
希望大家少遇bug,多点休息和学习时间~~~~
Biu~~