zoukankan      html  css  js  c++  java
  • NoUniqueBeanDefinitionException常见异常!!

    Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.cx.mapper.TInventoryMapper' available: expected single matching bean but found 2: TInventoryMapper,inventoryDao
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveNotUnique(DependencyDescriptor.java:221)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1225)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1167)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:457)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:435)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:559)
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:180)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:305)
    ... 27 more


    问题:此异常的原因是应为注入的mapper对象中有对象存在继承关系!
    解决方法:在注入的对象中加上此注解@Qualifier("对象名称")即可!!
    示列:
    @Resource
    @Qualifier("TInventoryMapper")
    private TInventoryMapper tInventoryMapper;

  • 相关阅读:
    Linux创建删除文件和文件夹
    Linux操作大全
    CentOS7从一般用户切换到root用户
    Eclipse一直building workspace问题解决
    maven项目启动找不到org.springframework.web.context.ContextLoaderListener
    java中如何补齐汉字字符
    java中如何根据函数查询引用的jar包
    delphi中Tkbmmemtable数据转成SQL脚本
    java设计模式(一)——单例模式
    UMl类图基本认识
  • 原文地址:https://www.cnblogs.com/flzidea/p/11380338.html
Copyright © 2011-2022 走看看