org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example......
发生这样的问题原因有以下几点
1.mapper接口类全名与mapper.xml的namespace不一致
例如:
mapper.xml位置在resources/mapper/mapper.xml但是你的mybatis配置确是
(mybatis:
mapperLocations: classpath:mapper/*/*.xml)
这样只能扫描到不到mapper/mapper.xml
正确的配置是
mybatis:
mapperLocations: classpath:mapper/*.xml或者将mapper.xml放到resources/mapper/*/mapper.xml的位置(*表示任何文件夹名称)
发生这样的问题原因有以下几点
1.mapper接口类全名与mapper.xml的namespace不一致
2.mapper接口的方法与mapper.xml的id不一致
3.mapper.xml的中文注释造成(去掉中文注释)
4.mapper.xml的路径与配置的不一致
例如:mapper.xml位置在resources/mapper/mapper.xml但是你的mybatis配置确是
(mybatis:
mapperLocations: classpath:mapper/*/*.xml)
这样只能扫描到不到mapper/mapper.xml
正确的配置是
mybatis:
mapperLocations: classpath:mapper/*.xml或者将mapper.xml放到resources/mapper/*/mapper.xml的位置(*表示任何文件夹名称)
5.idea中的resources有个标志如果没有则需要设置成resources
选择file-->Project Structure-->Moudules-->选择项目的resources文件夹-->点击Resources-->ok如图