0

I have a UserDetailsService class annotated with @Service. I also have DAO classes annonated which are autowiring and working fine within my controllers.

The problem is when I want to wire up the UserDetailsService bean within my security-context.xml. Spring is unable to find the bean. Is it because my component-scan is in my controllers.xml file and out of the scope of my security configuration?

xml config file layout as so :

web.xml :

<context-param>
    <param-name>contextConfigLocation</param-name>
        <param-value>
              /WEB-INF/spring/root-context.xml
              /WEB-INF/spring/appServlet/security-context.xml
        </param-value>
</context-param>

servlet-context.xml :

...
<beans:import resource="controllers.xml" />
...
Nilesh
  • 4,137
  • 6
  • 39
  • 53
briangallagher
  • 539
  • 4
  • 15
  • Also see http://stackoverflow.com/questions/4333390/service-are-constructed-twice/4335438#4335438 – axtavt Mar 07 '11 at 16:53

1 Answers1

3

Yes, you'll need to add the component scan to both contexts, it's not enough to do it in just one.

skaffman
  • 398,947
  • 96
  • 818
  • 769