SpringBoot中service注入失败(A component required a bean of type 'XXService' that could not found)
先写了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)的更多相关文章
- SpringBoot扫描不到类,注入失败A component required a bean of type 'XXService' that could...
SpringBoot项目的Bean装配默认规则是根据Application类所在的包位置从上往下扫描! “Application类”是指SpringBoot项目入口类.这个类的位置很关键: 如果App ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- SpringBoot:SpringBoot中@Value注入失败
1. 第一步检测语法是否正确 @Value("${test}") private String test; 2.第二步检测配置文件中是否有进行配置 url=testusername ...
- 记一个SpringBoot中属性注入失败的问题Consider defining a bean of type ''' in your configuration
今天遇到的一个问题: 代码检查了好几次,都没有错误,但是启动时就会报错Consider defining a bean of type ''' in your configuration. 启动类在c ...
- a commponent required a bean of type XXXXXX that could not be found-2022新项目
一.问题由来 目前刚入职一家新公司不久,公司的新项目采用DDD驱动领域设计来进行开发,架构这一块使用的是阿里巴巴开源的最新框架COLA4.0的架构. 主要是这个框架里面的分层设计.主要分为四层:ada ...
- 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 ...
随机推荐
- CF891C Envy(离线/在线+可撤销并查集/并查集/LCT)
前置知识 最小生成树及证明 做法 每个不同权值没影响,仅需判断该次询问每种权值是否在"小于该权值的所有边加完"之后,可以全部加进来 离线:询问的所有边全堆到一起,按权值排序,然后同 ...
- C# 使用大漠插件, 源码在Github和码云 ..希望对大家有所帮助
c# 使用大漠插件. 完成 类似 按键精灵的 功能. 方法 注释 正在慢慢的 完善中 目录 仓库 github 码云 准备 效果图 如何运行 1. 注册 大漠dll 到com (资源在 源码 DLL ...
- Linux下DM无法显示建模界面的解决方法
方法来源: http://www.linuxhospital.com/read/unable-to-resolve-function-glxqueryextension-in-hyperview.ht ...
- 06 、指令跳转:原来if...else就是goto
写好的代码编译成指令之后,一般正常流程是一条一条的顺序执行的.但是在程序中总会用到if...else这样的条件判断语句.while和for循环语句,还有函数或者过程调用,所以遇到这些程序编译的指令时是 ...
- Hadoop(一)—— 启动与基本使用
一.安装&启动 安装 下载hadoop2.7.2 https://archive.apache.org/dist/hadoop/common/hadoop-2.7.2/ 2.7.2-官方文档 ...
- postgresql大数据查询加索引和不加索引耗时总结
1.创建测试表 CREATE TABLE big_data( id character varying(50) NOT NULL, name character varying(50), dat ...
- 巧用 CSS 实现酷炫的充电动画
循序渐进,看看只使用 CSS ,可以鼓捣出什么样的充电动画效果. 画个电池 当然,电池充电,首先得用 CSS 画一个电池,这个不难,随便整一个: 欧了,勉强就是它了.有了电池,那接下来直接充电吧.最最 ...
- Hiberfil.sys
Hiberfil.sys 命令窗口中输入 powercfg -h off,即可关闭休眠功能,同时 Hiberfil.sys 文件也会自动删除.
- 页面的Tab选项卡 简单实例
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="C ...
- flutter Slider滑块组件
滑块,允许用户通过滑动滑块来从一系列值中选择. import 'package:flutter/material.dart'; class SliderDemo extends StatefulWid ...