Showing posts with label @Qualifier. Show all posts
Showing posts with label @Qualifier. Show all posts

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.

How to refer to another bean as a property in annotation-based configuration file

https://stackoverflow.com/questions/42386957/how-to-refer-to-another-bean-as-a-property-in-annotation-based-configuration-fil


 @Configuration
    class GlobalConfiguration {
        @Bean
        @Autowired
        public Example createExample(AnotherBean anotherBean){
            final Example example = new Example();
            example.setSomeProp(anotherBean);
            return example;
        }

        @Bean
        public AnotherBean createAnotherBean(){
            return new AnotherBean();
        }
    }

Azure - Pipeline - Add Approver for Stage

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