@Configuration, @Bean, @Component, @ComponentScan, @Import and @ImportResource
Learn @Configuration, @Bean, @Component, @ComponentScan, @Import and @ImportResource (Phase 4 · Spring Configuration (Core), Spring Core) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
@Configuration and @Bean • @Configuration marks a class as a source of bean definitions; @Bean methods are factory methods : the return value is registered as a bean named after the method. Parameters are injected by type (so @Bean methods can depend on each other through parameters). • Full vs lite mode : in a @Configuration class (CGLIB- enhanced ) calls between @Bean methods are intercepted so they return the same singleton ("inter-bean references"). In a plain @Component class (lite mode) or with @Configuration(proxyBeanMethods = false) the calls are ordinary Java calls and create new...