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;

  • 相关阅读:
    初试django
    初试mysql
    ASP.NET MVC 做的网站项目
    Update 更新语句使用两个表关联
    SQL Server 输出所有表结构
    循环数据集字段赋默认值
    FireBird.conf配置文件常用参数
    Delphi 获取临时数据集 ClientDataSet
    DELPHI 读取csv 格式文本文件
    获取 临时数据集 的两种方法
  • 原文地址:https://www.cnblogs.com/flzidea/p/11380338.html
Copyright © 2011-2022 走看看