Mybatis 报错ror parsing SQL Mapper Configuration.Could not find resource com.xxx/mapper/xxxMapper.xml

完整报错

org.apache.ibatis.exceptions.PersistenceException: 
### Error building SqlSession.
### The error may exist in com.xxx/mapper/xxxMapper.xml
### The error occurred while processing mapper_resultMap[IdCardWithPersonResult2]_association[card]
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com.xxx/mapper/xxxMapper.xml

虽然他说错误可能存在于xxxMapper.xml里面。

但是实际上可能存在于mybatis-config.xml配置文件里。

常常是因为里面的<mapper>里的路径写错。

比如,少写或多写或写错字母,或者/斜杠写成.点号了。

本例子中是因为斜杠写成了点号:

Could not find resource com.xxx/mapper/xxxMapper.xml

        <mapper resource="com.xxx/mapper/xxxMapper.xml"/>

    <mappers>
        <mapper resource="com.xxx/mapper/xxxMapper.xml"/>
    </mappers>

正确写法

        <mapper resource="com/xxx/mapper/xxxMapper.xml"/>

        要写.xml后缀。

    <mappers>
        <mapper resource="com/xxx/mapper/xxxMapper.xml"/>
    </mappers>
  • 7
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值