Where to put application level beans in Spring MVC? Into root-context.xml or into servlet-context.xml?
Where to put application level beans in Spring MVC? Into root-context.xml or into servlet-context.xml
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Beans declared in
root-context.xml(services) are visible for beans inservlet-context.xml(controllers), but not the other way around. Therefore there can be a dependency from controllers to services, but the reverse dependency is forbidden by Spring.That being said put MVC-independent code (services, DAOs, etc.) in main context and put web-only stuff in servlet context.