IDEA报Could not autowire. No beans of 'ProductCategoryMapper' type found(详细分析).
今天在写springboot案例的时候发现了Could not autowire. No beans of 'ProductCategoryMapper' type found.
意思为@Autowired没有起效,不能自动注入,beans对象的类型没有找到
上网查询资料发现可能错误如下:
1、@Service注解的包倒错了
正确的包为:
import org.springframework.stereotype.Service;
2、在你的Application类中 加上注解 @MapperScan
3、Mapper层(即dao接口层)没有加注解@Repository
我的错误为第三种,加上后不再报错
原因分析如下:
@Autowired可以对成员变量、方法和构造函数进行标注,来完成自动装配的工作,我们也要清楚,@Autowired是根据类型进行自动装配的。
@Repository(标识持久层)注解修饰哪个类,则表明这个类具有对对象进行CRUD(增删改查)的功能,而且@Repository是@Component注解的一个派生品,所以被@Repository注解的类可以自动的被@ComponentScan 通过路径扫描给找到。(这也在一定程度上解释了,为什么被@Repository注解的类才能@Autowired)
现象为报引用错。可是明明有这个类,就是引用不到呢。
最终,使用@Repository标记了mapper类。问题解决。
相关推荐
主要介绍了Idea 解决 Could not autowire. No beans of 'xxxx' type found 的错误提示,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
Think Python 中英文对照版2.05版 英文水平不高可以顺便学习英文
在idea2020 下写的spring5-autowired 小例子。person,cat dog ,给大家一个参考。
spring mybatis 整合activiti 初学例子,虽然没有jar包但有jar包的截图,找到一样或高版本的jar包可以运行,activiti最基本的例子,发起流程、待办任务、签收任务、处理任务(审批同意或不同意)、调整申请等功能;...
多线程Autowire注入null的解决方案.docx
object Server extends autowire. Server ... object ApiImpl extends Api def add ( x : Int , y : Int , z : Int ) = x + y + z } // client-side callsite import autowire . _ // needed for
以Spring5.3.6为演示基础,以多个范例显示演示了autowire多种形式的应用 default、byName、byType、constructor 并对相关使用做了一定的对比
Whether Spring should autoWire or not 是否自动绑定Spring struts.objectFactory.spring.useClassCache Whether Spring should use its class cache or not 是否spring应该使用自身的cache struts....
- Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1e7d503: defining beans [accountBizImpl,accountDaoImpl,baseMapperDaoImpl,org.springframework....
3.3.5. 自动装配(autowire)协作者 3.3.6. 依赖检查 3.3.7. 方法注入 3.4. Bean的作用域 3.4.1. Singleton作用域 3.4.2. Prototype作用域 3.4.3. Singleton beans和prototype-bean的依赖 3.4.4. 其他作用域 ...
3.3.5. 自动装配(autowire)协作者 3.3.6. 依赖检查 3.3.7. 方法注入 3.4. Bean的作用域 3.4.1. Singleton作用域 3.4.2. Prototype作用域 3.4.3. Singleton beans和prototype-bean的依赖 3.4.4. 其他作用域 ...
autowire自动导入句柄
Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright...
3.3.6. 自动装配(autowire)协作者 3.3.6.1. 设置Bean使自动装配失效 3.3.7. 依赖检查 3.3.8. 方法注入 3.3.8.1. Lookup方法注入 3.3.8.2. 自定义方法的替代方案 3.4. bean的作用域 3.4.1. Singleton作用域 3.4.2. ...
Autowire是Python的轻量级和简单的依赖注入库
封装通用的Spring3+Struts2+MyBatis3的CRUD+条件分页查询,... <bean id="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> </beans>
资源分类:Python库 所属语言:Python 使用前提:需要解压 资源全名:Autowire-1.0.0-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
3.3.6. 自动装配(autowire)协作者 3.3.7. 依赖检查 3.3.8. 方法注入 3.4. bean的作用域 3.4.1. Singleton作用域 3.4.2. Prototype作用域 3.4.3. 其他作用域 3.4.4. 自定义作用域 3.5. 定制bean特性 3.5.1...
要获取最新版本,请使用go1.16 +并使用go get命令获取它。 例如: go get github.com/go-autowire/autowire 要获取特定版本,请使用go1.16 +并使用go get命令获取它。 例如: go get github....