org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.build

使用SSM框架,添加一个新的Mapper.xml文件后,运行项目报错:

org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'Blog'.  Cause: java.lang.ClassNotFoundException: Cannot find class: Blog

开始我的Mapper是这样设置的:

<mapper namespace="com.online.dao.BlogDao">
    <!--保存Blog-->
    <insert id="saveBlog" parameterType="Blog">
       insert into blog(title,summary,content,htmlContent)values(#{title},#{summary},#{content},#{htmlContent});
    </insert>
</mapper>

原因是因为parameterType的路径不是完整路径,改为完整路径就可以了。

<mapper namespace="com.online.dao.BlogDao">
    <!--保存Blog-->
    <insert id="saveBlog" parameterType="com.online.domain.Blog">
        <selectKey keyProperty="id" keyColumn="id" resultType="int" order="AFTER">
            select last_insert_id();
        </selectKey>
        insert into blog(title,summary,content,htmlContent)values(#{title},#{summary},#{content},#{htmlContent});
    </insert>
</mapper>
原文地址:https://www.cnblogs.com/mxxbc/p/14039016.html