Problem with Autowiring & No unique bean

后端 未结 3 1796
执笔经年
执笔经年 2020-12-10 02:52

I have 2 classes (B,C) extends class A.

@Service
public class A  extends AbstratClass{

    @Autowired
    A(MyClass  br) {
        super(br);
         


        
3条回答
  •  被撕碎了的回忆
    2020-12-10 03:26

    You are trying (somewhere else) to autowire a bean of type A. Something like:

    @Autowired
    private A beanA;
    

    But you have 2 beans that conform to this.

    You can resolve this by using @Resource and specifying which bean exactly:

    @Resource("b")
    private A beanA;
    

    (where "b" is the name of the injected bean) or using the @Qualifier annotation.

提交回复
热议问题