在我的项目自动装配多级继承类我里面的它通过多级继承使用@Autowired注解相关的波纹管如何在春天MVC
@Component
@Scope("prototype")
class A{
}
@Component
@Scope("prototype")
class B extends A{
}
@Component
@Scope("prototype")
class C extends B{
}
现在三班我想C级对象Manager类
@Component(value = "manager")
@Scope("prototype")
class Manager {
@Autowired
A a;
@Autowired
B b;
@Autowired
C c;
......
}
这里一个和乙 CLAS的S对象被弹簧容器注入,但同时注入对象为Ç它是作为波纹管抱怨
nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.abc.bca.generator.sss.B] is defined: expected single matching bean but found 2: b,c
当我使用@Qualifier对于C类作为
@Autowired
@Qualifier('c')
C c
或
@Autowired
@Qualifier('c')
B c
它仍然显示相同的错误,所以我怎样才能得到对象为C类。
我认为限定符注释应该在类上,而不是在字段上。试试看。 –
我只是试过你的代码(没有@Qualifiers)。我没有看到任何例外..重新检查您的问题 – pvpkiran
在我的情况下,它是同样的例外 –