Autowire setter override with Java Config

前端 未结 3 1869
故里飘歌
故里飘歌 2021-01-15 03:27

Consider the following class:

public class MyBean {
    private A a;

    @Autowired(required=true)
    public void setA(A a) {
        this.a = a;
    }

           


        
3条回答
  •  长情又很酷
    2021-01-15 03:54

    If you have multiple candidates for injection you can specify the default one by using @Primary on the bean you want to be the default AImpl. That way no changes are needed to MyBean

提交回复
热议问题