|

Spring series, part 6: Spring 4 and Generics-based Injection Matching

Up until Spring 4 generics played no major role when it came to resolving injected bean dependencies. Suppose there are multiple beans of the same type implementing a generic interface. In a pre-Spring 4 world, any attempt to resolve such a bean by type would inevitably lead to a NonUniqueBeanDefinition exception, unless additional hints were…

|

Spring series, part 5: @Component vs @Bean

In this post, I will look into the distinction between a component and a bean. Even though both of them refer to Spring managed beans, each serves a different purpose. @Component and its specializations (@Controller, @Service and @Repository) allow for auto-detection using classpath scanning. @Bean on the other hand can only be used to explicitly…