No MyBatis mapper was found in '[XXXX]' package. Please check your configuration.

SpringBoot+Mybatis整合,后执行,报错 ,No MyBatis mapper was found in '[XXXX]' package. Please check your configuration.

第一步,检查applications.yml配置文件,

mybatis:
  typeAliasesPackage: pojo路径
  mapperLocations: classpath:mapper/*.xml

第二步,检查mapper.xml文件中的路径是否正确

第三步,在Application文件中增加

@MapperScan("XXX.XXX.XXX.mapper")

第四步,在mapper.java中增加注解@Mapper

添加第三步和第四步内容后,启动成功!

回答: 这个问题的原因是在指定的包路径下没有找到MyBatisMapper接口。根据引用\[1\]中的报错日志,可以看到警告信息" No MyBatis mapper was found in '\[com.taiji\]' package. Please check your configuration."。解决这个问题的方法是在项目内的某个路径下建立一个接口,并在接口上添加@Mapper注解。需要注意的是,这个接口不能在@MapperScan注解定义的basePackage路径下,否则会出现另外一个新的警告"Skipping MapperFactoryBean with name xx Bean already defined with the same name!"。这是因为在启动时,Spring Boot的默认basePackage会被MyBatis-Plus的自动配置拿来作为基目录去扫描是否有带有@Mapper注解的接口需要注册到Spring容器中。如果没有这个注解,则会报错。同时,如果@Mapper注解定义的接口在@MapperScan注解定义的路径下,会导致重复扫描创建bean的问题。因此,需要确保这两个注解不在同一个路径下。\[1\]\[3\] #### 引用[.reference_title] - *1* [MyBatis(或Plus):找不到xml文件。No MyBatis mapper was found in ‘[com.**.**.mapper]‘ package](https://blog.csdn.net/qq_16946803/article/details/121470227)[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^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [No MyBatis mapper was found in ‘[xxx.mapper]‘ package. Please check your configuration.](https://blog.csdn.net/GaoL77/article/details/129168248)[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^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [No MyBatis mapper was found in ‘[xx.mapper]‘ package. Please check your configuration.特殊处理](https://blog.csdn.net/h15915793385/article/details/122893729)[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^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值