Field baseMapper in xxxxx required a bean of type 'xxxxxx' that could not be found 问题
最近在整合spring boot 和通用mapper时遇到错误,纠结了好长时间,先看错误
Description:Field baseMapper in com.sinosoft.common.mybatis.service.impl.BaseServiceImpl required a bean of type 'com.sinosoft.common.mybatis.mapper.MyBaseMapper' that could not be found.Action:Consider defining a bean of type 'com.sinosoft.common.mybatis.mapper.MyBaseMapper' in your configuration.Process finished with exit code 1
问题解决思路
1.先看下pom,下边是整合通用mapper所须的依赖
<!--mysql--><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency><!--mybatis--><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>1.3.0</version></dependency><!-- pagehelper分页插件 --><dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>1.2.3</version></dependency><!-- 通用mapper --><dependency><groupId>tk.mybatis</groupId><artifactId>mapper-spring-boot-starter</artifactId><version>2.0.2</version></dependency><!-- 阿里巴巴druid数据库连接池 非必须 --><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.0.18</version></dependency>
2.代码目录结构
3.需要检查的点
3.1basemapper 不能和业务类的mapper放在同一目录下
3.2service实现类应该抽象的避免被通用mapper扫描
public abstract class BaseServiceImpl<T,ID extends Serializable> implements BaseService<T,ID> {@Autowiredpublic MyBaseMapper<T> baseMapper;
3.3业务类mapper应该加上@Mapper注解,或者在spring boot启动类上添加@MapperScan注解
@Mapper
public interface MusicMapper extends MyBaseMapper<MusicModel> {}
@SpringBootApplication
@MapperScan(basePackages ={"com.sinosoft.musicproxy.mapper"})
public class MusicProxyApplication {public static void main(String[] args) {SpringApplication.run(MusicProxyApplication.class, args);}
}
3.4业务类应该继承你自己的通用mapper接口。我自己的错误就是吧MyBaseMapper写成了BaseMapper(这个错误是真的低级)
//错误
@Mapper
public interface MusicMapper extends BaseMapper<MusicModel> {}//正确
@Mapper
public interface MusicMapper extends MyBaseMapper<MusicModel> {}
3.5namespace对应接口名
<mapper namespace="com.sinosoft.musicproxy.mapper.MusicMapper" >
package com.sinosoft.musicproxy.mapper;/*** @author fxl* @Title: ${file_name}* @Package ${package_name}* @Description: ${todo}* @date 2018-06-149:55*/
@Mapper
public interface MusicMapper extends BaseMapper<MusicModel> {}
3.6.还有可能是你的某些mapper没有加@mapper注解,也会出现这种情况
这算我在遇到这个问题在网上找到解决方法吧,希望别有人跟我一样犯同样的错误,特别是低级错误。写的不好,见谅。
Field baseMapper in xxxxx required a bean of type 'xxxxxx' that could not be found 问题相关推荐
- Field xxxMapper in xxxxxxx required a bean of type ‘xxxxMapper‘that could not be found.
问题: Description: Field xxxMapper in xxxxxxx required a bean of type 'xxxxMapper'that could not be fo ...
- SpringBoot报错Field userService in XXTestController required a bean of type 'XX' that could not be...
运行SpringBoot项目报错Field userService in XXXTestController required a bean of type 'XXX' that could not ...
- 多模块项目依赖注入失败Field xxRepository in xxImpl required a bean of type xxRepository that could not be found
错误场景:多模块项目,依赖注入失败 今天新搭了个多模块服务,controller和service,repository是在不同的模块中的,在controller的模块中导入service,reposi ...
- springboot踩坑日记——Field xxx.xxx.xxx required a bean of type 'xxx.xxx.xxx' that could not be found
使用feign时报创建的feign接口找不到 Field xxx.xxx.xxx required a bean of type 'xxx.xxx.xxx' that could not be fou ...
- 使用Feign服务远程调用项目启动时报错:Field xxx in xxx required a bean of type xxx that could not be found.
报错: *************************** APPLICATION FAILED TO START ***************************Description:F ...
- mybatis Field xxxMapper in xxxx required a bean of type 'XXXMapper' that could not be found.
错误如下: 2017-05-11 16:15:32.410 [main] INFO o.a.catalina.core.StandardService - Stopping service Tomca ...
- springboot Field userInfoInter in com.**.** required a bean of type ‘***.**‘
问题: Field userInfoInter in com.yyjc.springboot.service.UserInfoService required a bean of type 'com. ...
- springboot 配置RedisTemplate 报:Field redisTemplate in XXX required a bean of type 'org.springframework
错误信息如下: Error starting ApplicationContext. To display the conditions report re-run your application ...
- SpringBoot 项目中在Controller 直接调用Mapper,提示:Field mapper in ‘*Controller ‘ required a bean of type ‘*Map
今天使用IDEA 搭建SpringBoot 项目,我心血来潮想省略Service 层的编写就直接在Controller 层调用Mapper 层接口,提示如下错误信息: **************** ...
最新文章
- Xtrabackup对mysql全备以及增量备份实施
- JS中toFixed()方法的问题及解决方案
- 如何在android中创建自定义对话框?
- cachecloud:Redis云管理平台
- Linux popen和pclose启动shell命令的问题思考
- 数据分析数据拼接案例
- AngularJS 事件
- linux chattr修改文件属性,linux chattr(改变文件属性)
- 基于JAVA+SpringMVC+Mybatis+MYSQL的网上医院预约挂号系统
- Android用户分类管理,腾讯手机管家Android 7.10上线,微信整理助手实现智能精准分类...
- 招聘云计算、虚拟化、前端开发、测试等工程师
- 24c存储器读写软件_必知必会-存储器层次结构
- 这 4 款电脑记事本软件,得试试
- ORACLE建表sql
- 服务器名称指示(SNI)是什么东东?
- win7系统备份还原软件_比ghost快200%!备份还原系统真正首选的神器
- 《你的降落伞是什么颜色》-- 读书笔记
- Maven-仓库概念,下载与配置
- adb 判断imei_获取设备序列号 SN码(对应:设置-关于手机-状态-序列号 )
- 「JVM 故障诊断」故障分析与处理案例
热门文章
- C语言和Bash脚本实现身份证号码尾号验证
- 计算起始时间与结束时间之间有哪些月份和周数
- 2022华中杯数学建模思路
- 【OpenCV-Python】教程:5-3 光流
- 【python实现视频解帧并保存到文件夹】
- 怎样实现在单片机上跑LINUX系统,简述Linux如何应用在嵌入式单片机上
- 异常信息:由于内部错误,服务器无法处理该请求。有关该错误的详细信息,请打开服务器上的 IncludeExceptionDetailInFaults
- DaVinci:HDR 调色
- 阿里跟腾讯又㕛叒打起来了,这次是在东南亚
- 知识点四 图论:dijkstra (HDU 2544 +HDU 1874)