How to solve the error "Field service in com.xx.xxx.xxxx required a bean of type 'com.aa.bb.cc' that could not be found."
When runung a SpringBoot demo, I got a error as following:
*************************** APPLICATION FAILED TO START *************************** Description: Field service in com.hy.empcloud.EmpControl required a bean of type 'com.hy.empcloud.EmpService' that could not be found. The injection point has the following annotations: - @org.springframework.beans.factory.annotation.Autowired(required=true) Action: Consider defining a bean of type 'com.hy.empcloud.EmpService' in your configuration.
After I add a annotation "@Service" to the class com.hy.empCloud.EmpService, the error was solved.
package com.hy.empcloud; import java.util.ArrayList; import java.util.List; import org.springframework.stereotype.Service; // To provide service of employees @Service public class EmpService { private List<Emp> emps; public EmpService(){ emps=new ArrayList<Emp>(); emps.add(new Emp(1,"Andy",41)); emps.add(new Emp(2,"刘德华",42)); emps.add(new Emp(3,"Bill",43)); emps.add(new Emp(4,"比尔",44)); } public List<Emp> getAll(){ return emps; } public Emp find(long id) throws Exception{ for(Emp e:emps) { if(e.getId()==id) { return e; } } throw new Exception("No such employee whose's id="+id); } }
Here is the demo.
--END--
2019年8月24日14点24分
How to solve the error "Field service in com.xx.xxx.xxxx required a bean of type 'com.aa.bb.cc' that could not be found."的更多相关文章
- Field userService in com.wuji.controller.UserController required a bean of type 'com.wuji.service.UserService' that could not be found
Field userService in com.wuji.controller.UserController required a bean of type 'com.wuji.service.Us ...
- 解决办法 Field userService in com.sxsj.controller.RegistLoginController required a bean of type
转自:https://blog.csdn.net/awmw74520/article/details/82687288 APPLICATION FAILED TO START Error starti ...
- Visual Studio 2022 git error Unable to negotiate with xx.xxx.xxxx port 22: no matching host key type found. Their offer: ssh-rsa
前言 前两天因为升级了Git导致git提交拉取的时候都提示下面这个异常,然后经过一番折腾以后终于把这个问题解决了.但是今天我升级了下Visual Studio 2022将其升级到了17.1.3版本然后 ...
- 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 ...
- 解决:Field xxMapper in xx.service.impl.xxServiceImpl required a bean of type 'xx.mapper.xxMapper'
1.启动 SpringBoot项目报错,使用的是Springboot.Spring.Mybatis连接Mysql数据库,启动SpringBoot项目报错,错误如下所示: _____ .__/\ .__ ...
- Spring Cloud Ribbon负载均衡配置类放在Spring boot主类同级增加Exclude过滤后报Field config in com.cloud.web.controller.RibbonConfiguration required a bean of type 'com.netflix.client.config.IClientConfig' that could not b
环境: Spring Cloud:Finchley.M8 Spring Boot:2.0.0.RELEASE 目录结构: 可以看到代码第13行的注释,我已经在@ComponentScan注解中添加了E ...
- 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 ...
- maven多模块启动required a bean of type com.xxx.xxx.service that could not be found.
Description: Field testService in com.xxx.xxx.api.controller.TestController required a bean of type ...
- 运行springboot项目报错:Field userMapper in XX required a bean of type 'xx' that could not be found.
运行springboot项目报错: *************************** APPLICATION FAILED TO START ************************** ...
随机推荐
- html/form表单常用属性认识
1.form表单常用属性练习 <style> .form1 { margin: auto; height: 900px; width: 500px; text-align: center; ...
- IDEA + SpringBoot + maven 项目文件说明
Springboot + maven + IDEA + git 项目文件介绍 1..gitignore 分布式版本控制系统git的配置文件,意思为忽略提交 在 .gitingore 文件中,遵循相应 ...
- NTL 库函数
NTL是一个高性能,可移植的C ++库,为任意长度的整数提供数据结构和算法; 可用于整数和有限域上的向量,矩阵和多项式; 可用于任意精度浮点运算. NTL为以下方面提供高质量的最先进算法实现: 任意长 ...
- 常用的商业级和免费开源Web漏洞扫描工具
Scanv 国内著名的商业级在线漏洞扫描.可以长期关注,经常会有免费活动.SCANV具备自动探测发现无主资产.僵尸资产的功能,并对资产进行全生命周期的管理.主动进行网络主机探测.端口探测扫描,硬件特性 ...
- Shell编程备份数据库
案例: 在/usr/sbin/建立Shell文件 备份后查看目录: 然后进行crontab任务调度: #每天凌晨两点十分调度一次 * * * /usr/sbin/mysql_db.sh
- 1.(基础)tornado初识
tornado的话就不带着大家看源码了,今后可能会介绍,目前只是看简单的用法,而且当前的tornado版本不高,其实说白了这是很久以前写的文档,但是由于格式的原因,所以打算用Markdown重写一次. ...
- traceback:让你更加灵活地处理python的异常
异常 异常在python中是屡见不鲜了,程序在执行到某一行代码时,发现有问题,比如数组索引越界,变量没有定义啊等等,此时就会抛出异常 捕获异常 在python,一般都是使用try···except来对 ...
- poj1015 Jury Compromise[背包]
每一件物品有两个属性.朴素思想是把这两种属性都设计到状态里,但空间爆炸.又因为这两个属性相互间存在制约关系(差的绝对值最小),不妨把答案设计入状态中,设$f[i][j]$选$i$个人,两者之差$j$. ...
- html访问全过程
1)解析Web页面的URL,得到Web服务器的域名 2)通过DNS服务器获得Web服务器的IP地址 3)与Web服务器建立TCP连接 4)与Web服务器建立HTTP连接 5)从Web服务器获得URL指 ...
- CentOS7.2 安装 PHP7.2
安装源 安装 EPEL 软件包: $ sudo yum install epel-release 安装 remi 源: $ sudo yum install http://rpms.remirepo. ...