I've searched for an answer to this question but my search voodoo must be a little off.
At work I've noticed there's a preference to use Spring Configuration and @Beans to initialise our Java objects. While there is no problem with this approach I thought switching over to @Component (with ComponentScan) might
- Slightly simplify the code
- Put us more inline with good Spring practices
But, thinking about it, I'm having trouble justifying why I consider it a good practice. My understanding of @Bean is that it's useful for initialising legacy or non-Springified, code. That may be causing me to consider @Component as a good practice.
An advantage to the @Bean approach is that it centralises the initialisation. This is a little easier to understand in contrast to @Component which is not as immediately intuitive.
Does Spring have any good documentation on the pros and cons of each approach? Or a best practices guide for this topic?