org.apache.ibatis.binding.BindingException: Type interface com.bjwl.pojo.StudentDao is not known to the MapperRegistry
时间: 2023-11-28 20:42:59 浏览: 48
org.apache.ibatis.binding.BindingException: Type interface com.bjwl.pojo.StudentDao is not known to the MapperRegistry是MyBatis框架中的一个异常,它表示MapperRegistry无法识别com.bjwl.pojo.StudentDao接口类型。这通常是由于没有正确配置映射文件或没有将接口与映射文件正确关联引起的。解决此问题的方法是检查以下几点:
1. 确保在mybatis-config.xml文件中正确配置了映射器。
2. 确保在映射器配置文件中正确指定了命名空间和接口。
3. 确保接口的包路径和映射器配置文件中的命名空间相同。
4. 确保接口方法名称和映射器配置文件中的SQL语句ID相同。
5. 确保接口方法参数类型和映射器配置文件中的SQL语句参数类型相同。
相关问题
org.apache.ibatis.binding.BindingException: Type interface qst.mapper.UserMapper is not known to the MapperRegistry.
引用中提到,出现这种情况的主要原因是主配置文件标签没有正确指向映射接口的配置文件。解决方案可以是检查<mapper>的class属性或resource属性,确保路径和文件名的正确性。在引用中还提到,使用命名参数可以在传递参数时给参数加上注解,示例代码如下所示:
```
public Employee getEmpByIdandName(@Param("id") Integer id, @Param("name") String name);
```
而在引用中,指定参数的方法如下所示:
```
<select id="getEmpByIdandName" resultType="com.qst.mybatis.Employee">
select * from employee where id = #{param1} and name= #{param2}
</select>
```
根据错误信息"org.apache.ibatis.binding.BindingException: Type interface qst.mapper.UserMapper is not known to the MapperRegistry.",请检查以下几个方面:
1. 确保UserMapper接口的包路径和文件名正确。
2. 确保主配置文件中的<mapper>标签中的class属性或resource属性引用了正确的UserMapper接口配置文件。
3. 确保UserMapper接口中的方法名和映射文件中的sql语句id一致。
org.apache.ibatis.binding.BindingException: Type interface com_atguigu.mybatis.mapper.UserMapper is not known to the MapperRegistry.
回答: 这个问题是由于核心配置文件中加载映射文件的包名写错导致的。具体来说,错误的包名是"com_atguigu.mybatis.mapper.UserMapper",而正确的包名应该是"com.atguigu.mybatis.mapper.UserMapper"。这个错误会导致MyBatis无法识别到UserMapper接口。解决这个问题的方法是将包名修改为正确的形式,即将"com_atguigu.mybatis.mapper"改为"com.atguigu.mybatis.mapper"。这样就能够正确加载映射文件并解决该异常。\[1\]\[2\]\[3\]
#### 引用[.reference_title]
- *1* [解决 - org.apache.ibatis.binding.BindingException: Type interface com.itheima.mapper.UserMapper...](https://blog.csdn.net/weixin_51730356/article/details/129260822)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [解决org.apache.ibatis.binding.BindingException: Type interface is not known to the MapperRegistry.](https://blog.csdn.net/WHT869706733/article/details/123271534)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [org.apache.ibatis.binding.BindingException: Type interface xxx.Mapper is not known to the MapperRegi](https://blog.csdn.net/RadNICkMan/article/details/125381881)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]