问题:mybtis报错:org.apache.ibatis.binding.BindingException: Type interface com.joinbright.iot.alarmer.utils.mybatis.dao.AlarmingDataMapper is not known to the MapperRegistry.
原因:项目中配有2个实体类↓

打包后只有1个实体类↓

分析:项目打包时配置文件为旧文件,未更新。当执行数据库操作时就会失败↓

解决办法:在pom.xml中增加如下配置,打包时更新xml文件

<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
</includes>
<excludes>
<!--<exclude>*.properties</exclude>-->
<!--<exclude>*.xml</exclude>-->
<!--<exclude>mapper/*.xml</exclude>-->
</excludes>
</resource>
</resources>
该博客讲述了在使用MyBatis时遇到的BindingException错误,问题源于打包后实体类缺失导致MapperRegistry无法识别。分析指出是打包配置文件未更新,使得数据库操作失败。解决方法是在pom.xml中添加资源配置,确保打包时更新XML文件,从而避免此类问题。
384





