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

在使用SSM框架时,添加Mapper.xml文件后遇到运行错误:org.apache.ibatis.builder.BuilderException。错误根源在于Mapper XML的parameterType路径不正确。修复方法是将parameterType的值更改为完全限定类名,确保路径完整,从而消除错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值