Sep 4th, 2008, 11:14 AM
How to decide which class will be Spring Bean
I am new to Spring and I think I understood inversion of control , and I can understand simple projects (mostly related to the DAO). But when I need to decide which classes to be Spring Bean, the only ones that come in mind are
DAO classes (because of DataSource injection).
Can you please help me and explain how I decide which classes should be Spring Beans (in spring repository). Is there some heuristics about this?
Thank you very much,
Sep 4th, 2008, 01:47 PM
What kind of project are you building?
The beauty is that any object can be a spring bean. If you program towards interfaces, then you can nicely do the wiring of your objects using spring.
In a standalone app for instance, you only need to instantiate the spring context (ApplicationContext). From there spring instantiates all your dependencies.