先写了JUnit,发现启动不了,注释掉有问题的service也不可以。可能是因为spring开始时会加载所有service吧。

按照网友们的说法,一般需要检查:

1.入口类有没有写MapperScan

我写了,没问题:)

@MapperScan(basePackages="com.example.demo.mapper")

2.该service对应的dao接口上没写@Mapper

我写了,没问题:)

3.@Service里的字符串与该service名称不一致

由于我这个service是个接口,所以@Service是写在实现类里的,过去检查了一下,发现确实不一致,首字母一个大写一个小写。

但是我有另一个正常运行的service,它也是一样的情况,不一致。所以问题应该不是这里。

但是为了不出错,还是改成一致比较好。

随后我发现。。。

我的实现类没有写implements哪个接口????

所以当然没有办法注入这个bean啊:)修改:

总结:

目前配置方面已经踩完很多坑了,所以之后再报错,要首先检查你的代码。。。

我是Ruriko,我爱这个世界:)

SpringBoot中service注入失败(A component required a bean of type 'XXService' that could not found)的更多相关文章

  1. SpringBoot扫描不到类,注入失败A component required a bean of type 'XXService' that could...

    SpringBoot项目的Bean装配默认规则是根据Application类所在的包位置从上往下扫描! “Application类”是指SpringBoot项目入口类.这个类的位置很关键: 如果App ...

  2. STS中不同包但相同类名引起的问题:A component required a bean of type 'javax.activation.DataSource' that could not be found

    1. 问题输出: APPLICATION FAILED TO START*************************** Description: A component required a ...

  3. Sping Cloud项目启动报A component required a bean of type 'com.tianyan.bbc.dao.SecurityUserBaseMapper' that could not be found.

    项目构建正常,启动和Debug报以下错误: Error starting ApplicationContext. To display the conditions report re-run you ...

  4. Java报错: A component required a bean of type 'com.sirifeng.testmybatis.mapper.BookMapper' that could not be found.

    在学习Spring-boot-mybatis时,报错A component required a bean of type 'com.sirifeng.testmybatis.mapper.BookM ...

  5. springboot jpa mongodb 整合mysql Field in required a bean of type that could not be found Failed to load ApplicationContext

    1.完整报错 *************************** APPLICATION FAILED TO START *************************** Descripti ...

  6. SpringBoot:SpringBoot中@Value注入失败

    1. 第一步检测语法是否正确 @Value("${test}") private String test; 2.第二步检测配置文件中是否有进行配置 url=testusername ...

  7. 记一个SpringBoot中属性注入失败的问题Consider defining a bean of type ''' in your configuration

    今天遇到的一个问题: 代码检查了好几次,都没有错误,但是启动时就会报错Consider defining a bean of type ''' in your configuration. 启动类在c ...

  8. a commponent required a bean of type XXXXXX that could not be found-2022新项目

    一.问题由来 目前刚入职一家新公司不久,公司的新项目采用DDD驱动领域设计来进行开发,架构这一块使用的是阿里巴巴开源的最新框架COLA4.0的架构. 主要是这个框架里面的分层设计.主要分为四层:ada ...

  9. 2. springboot启动报错:Field userMapper in com.service.UserService required a bean of type 'com.dao.UserMapper' that could not be found.

    报错信息: 2018-06-25 14:26:17.103  WARN 49752 --- [  restartedMain] ationConfigEmbeddedWebApplicationCon ...

随机推荐

  1. fluent求平均温度、最高低温度和平均传热系数【转载】

    摘自<ANSYS FLUENT技术基础与工程应用:流动传热与环境污染控制领域> 一.平均温度的计算: 双击导航栏中Result下方的Report进入Report任务页面,双击其中的Volu ...

  2. De1ctf - shell shell shell记录

    虽然是N1CTF原题,但是自己没遇见过,还是做的题少,记录一下吧== 1.源码泄露,直接可以下到所有源码,然后代码审计到一处insert型注入: 这里直接带入insert里面,跟进去看看 insert ...

  3. HikariCP 连接最快的连接池

    三点原因 1.字节码精简 2.自定义 FastList 代替ArrayList ;避免每次get()调用都要进行range check,避免调用remove()时的从头到尾的扫描: 3.优化代码和拦截 ...

  4. 批量管理工具:pssh/ansible

    ssh 免密码 批量管理1.创建用户useradd user1echo “123456”| passwd --stdin user12.创建秘钥ssh-keygen -t dsa然后一直回车 非交互式 ...

  5. 小D课堂 - 零基础入门SpringBoot2.X到实战_第三节SpringBoot热部署devtool和配置文件自动注入实战_14、SpringBoot2.x使用Dev-tool热部署

    学习笔记 热部署 每次修改了代码都需要关闭应用重启 热部署就是有一个插件会监听我们应用的代码文件是否有变化,如果有变化就会有其他的类加载器加载 主要的依赖 复制到我们的pom.xml里面 安装完成ja ...

  6. Flutter 目录结构介绍、入口、自定义 Widget、MaterialApp 组件、Scaffold 组件

    Flutter 目录结构介绍 文件夹 作用 android android 平台相关代码 ios ios 平台相关代码 lib flutter 相关代码,我们主要编写的代 码就在这个文件夹 test ...

  7. ISO/IEC 9899:2011 条款6.8.5——迭代语句

    6.8.5 迭代语句 语法 1.iteration-statement: while    (    expression    )    statement do    statement    w ...

  8. 五、postman-sandbox

    一.在postman中运行一些JavaScript代码的地方 公共库(javascript) 环境变量与全局变量 动态变量 操作cookie 获取和查看请求及响应 读取数据文件 二.api文档 htt ...

  9. MFC加载osg模型

    创建MFC单文档项目, OSGObject.h #pragma once #include <osgViewer\Viewer> #include <osgDB\ReadFile&g ...

  10. 安卓 android studio 报错 Could not find com.android.tools.build:gradle:3.2.1.

    报错截图如下: 解决方法:在project的builde.gradle做如下操作分别加上google()