Close

Spring - Beans Auto-Wiring

[Last Updated: Nov 28, 2020]

Spring container can autowire dependencies implicitly. We can specify a mode of autowiring using @Bean annotation.

@Configuration
 public class Config{
    @Bean(autowire == <autowireMode>)
     public ABean aBean(){
        return new ABean();
    }
   .....
 }


The valid values of autowiring modes are: Autowire.NO, Autowire.BY_NAME and Autowire.BY_TYPE


In next tutorials we will see the examples of each autowiring mode.

See Also