Could not autowire. No beans of 'EmployeeMapper' type found.
时间: 2023-10-28 12:24:49 浏览: 154
"Could not autowire. No beans of 'EmployeeMapper' type found."这个错误通常表示Spring容器无法找到'EmployeeMapper'类型的bean。解决这个问题的方法有以下几种:
1. 在Mapper接口文件上添加@Repository注解,代表数据访问。这样可以让Spring容器识别'EmployeeMapper'接口并将其注册为bean。
2. 将@Mapper注解改为@Repository。这样可以让Spring容器将'EmployeeMapper'接口识别为一个Repository bean,从而解决找不到bean的问题。
3. 尝试将@Autowrited注解改为@Autowrited(required = false)。这样可以让Spring容器在找不到'EmployeeMapper'类型的bean时不抛出异常,而是使用null值注入。注意,这种方法可能会导致其他地方使用'EmployeeMapper'时出现NullPointerException。
请根据具体情况选择适合的解决方法来解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Could not autowire. No beans of ‘xxxMapper‘ type found.](https://blog.csdn.net/weixin_44575373/article/details/126218971)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [idea报“Could not autowire. No beans of ‘UserMapper‘ type found. ”错解决办法](https://blog.csdn.net/weixin_41963554/article/details/109451015)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文