Monday, February 1, 2021

@Autowired Conflicts Management

https://howtodoinjava.com/spring-core/spring-beans-autowiring-concepts/

https://stackoverflow.com/questions/40830548/spring-autowired-and-qualifier/48134386

https://www.baeldung.com/spring-qualifier-annotation

https://mkyong.com/spring/spring-autowiring-qualifier-example/


@Qualifier Example

To fix above problem, you need @Quanlifier to tell Spring about which bean should autowired.


package com.mkyong.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

public class Customer {

    @Autowired
    @Qualifier("personA")
    private Person person;
    //...
}

In this case, bean “personA” is autowired.

No comments:

Post a Comment

Azure - Pipeline - Add Approver for Stage

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass