mybatis中出现Invalid bound statement (not found)
2017-08-06 10:24
441 查看
近日博主在玩solr的自动导入数据库数据的时候,因为有用到mybatis,由于各方面写的都没问题,然而一直出现Invalid bound statement (not found)这个问题,数据导入不进去,进过几天查资料发现是绑定失败xml文件并没有发布到目录文件中,困扰了很久最终在pom文件中添加如下解决,此文做下记录:
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
总结下排出思路:
1,先查看mapper.java文件的方法是否适合xml文件中的sql的id一致
2,查看xml文件中引入的namespace是否可以点进去,点到java文件
3,查看xml文件中的resultType是否是正确
4,最后在考虑是否发布到目录文件中
谢谢,不喜勿喷
在补充一项就是,当项目中使用两种方式进行映射xml文件时的情景,楼主在写项目的时候,。出现使用了xml的方式进行SQL的映射,同时又写的DAO层的实现类,这个时候如果两个接口一起扫描到了的话,当执行DAO接口的时候就会默认去找xml文件的绑定,而不去找实现类,所以配置dao的扫描包的时候要注意只要扫描到xml文件包即可,范围不要太大了。
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
总结下排出思路:
1,先查看mapper.java文件的方法是否适合xml文件中的sql的id一致
2,查看xml文件中引入的namespace是否可以点进去,点到java文件
3,查看xml文件中的resultType是否是正确
4,最后在考虑是否发布到目录文件中
谢谢,不喜勿喷
在补充一项就是,当项目中使用两种方式进行映射xml文件时的情景,楼主在写项目的时候,。出现使用了xml的方式进行SQL的映射,同时又写的DAO层的实现类,这个时候如果两个接口一起扫描到了的话,当执行DAO接口的时候就会默认去找xml文件的绑定,而不去找实现类,所以配置dao的扫描包的时候要注意只要扫描到xml文件包即可,范围不要太大了。
相关文章推荐
- IntelliJ IDEA使用Maven创建Spring和Mybatis工程出现...BindingException: Invalid bound statement (not found)
- 当mybatis整合spring后出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- 测试spring,mybatis时出现.BindingException: Invalid bound statement (not found): com.imooc.dao.Secki
- mybatis maven打包出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误
- 关于IDEA工具在springboot整合mybatis中出现的Invalid bound statement (not found)问题
- mybatis出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- mybatis绑定错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- "Invalid bound statement (not found): com.sitech.admin.dao.TbOpenAbilityInfoDao.findAbilityReadyUp"mybatis配置文件bug
- mybatis一个怪异的问题: Invalid bound statement (not found)
- mybatis错误:Invalid bound statement (not found)
- Eclipse中Mybatis无法读取xml文件的问题(mybatis绑定错误-- Invalid bound statement (not found))
- IDEA的maven项目出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误解决方法
- springMvc+Mybatis关于 Invalid bound statement (not found):的错误
- Mybatis在idea中错误:Invalid bound statement (not found)
- mybatis一个怪异的问题: Invalid bound statement (not found)
- mybatis “org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)”
- Mybatis中Invalid bound statement (not found): com.atguigu.mybatis.dao.EmployeeMapper.getEmpById报错问题
- [MyBatis]诡异的Invalid bound statement (not found)错误
- MyBatis绑定错误提示BindingException:Invalid bound statement (not found)的解决方法
- 单元测试出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)