先写了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. requests库详解

    import requests #实例引入 # response = requests.get('http://www.baidu.com') # print(type(response)) # pr ...

  2. Java设计模式之三建造者模式和原型模式

    建造者模式 简介 建造者模式是属于创建型模式.建造者模式使用多个简单的对象一步一步构建成一个复杂的对象.这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式.简单的来说就是将一个复杂的东西 ...

  3. book-rev8 Chapter 0 Operating system interfaces

    Chapter 0 第0章 Operating system interfaces 操作系统接口 The job of an operating system is to share a comput ...

  4. python 生成 pyc 文件

    以 pyc 为扩展名的是Python的编译文件.其执行速度快于 py 文件且不能用文本编辑编辑查看.所以 pyc 文件往往代替 py 文件发布. Python 在执行时,首先会将 py 文件中的源代码 ...

  5. Linux下通过nmap扫描局域网内设备,获取ip地址和mac地址

    安装nmap sudo apt-get install nmap 扫描  sudo nmap -sP -PI -PT

  6. [XLua]热更新四部曲视频教程+示例源码

    基于Unity2017 xLua是由腾讯维护的一个开源项目,xLua为Unity. .Net. Mono等C#环境增加Lua脚本编程的能力,借助xLua,这些Lua代码可以方便的和C#相互调用.自20 ...

  7. Python脚本基础运算和算法

    原文地址:https://www.cnblogs.com/ailiailan/p/10141741.html 通过关注“常见”脚本,是对代码的一个很好的学习和总结的方式. 1.冒泡排序 lis = [ ...

  8. Hive跨集群迁移

    Hive跨集群迁移数据工作是会出现的事情, 其中涉及到数据迁移, metastore迁移, hive版本升级等. 1. 迁移hdfs数据至新集群hadoop distcp -skipcrccheck ...

  9. 为什么要监控sql语句?如何监控?

    01 为什么要监控sql语句? ① 因为程序大了以后,sql语句有可能被多个地方调用 .你不能确认当前时间是不是只执行了你需要的那条语句 . ② 有的持久层框架采用linq的语法来写sql , 程序中 ...

  10. c++异常——学习笔记

    1.异常 throw抛出字符串 最好的是:throw抛出对象. catch(...){} 2.使用标准异常类 #include<new> bitset 自己写一个异常 设计自己异常类 堆栈 ...