Monday, February 1, 2021

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();
        }
    }

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