I am using a custom UserDetailsService to authenticate users. This uses a PersonDao/Service object that is autowired. To autowire this object, I had to include reference to datasource, sessionfactory and annotation driven in Spring-security-context.xml. All these lines are exactly replicated in app-servlet.xml. So I was wondering if there is anyway to have theses lines in only one place and not to copy it at both the places.
I am using a custom UserDetailsService to authenticate users. This uses a PersonDao/Service object
Share
Your app-servlet (Spring MVC) context is a child of the root WebApplicationContext and has access to all of the beans in the parent.
If your parent context includes spring-security-context (for example)
then app-servlet will have access to those beans.
See What's a smart way to organize classes in Spring 3 for component-scan? for info on how to not duplicate beans when
<component-scan>ing.