开发者

Spring Component scanned bean not accessable

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" />
...


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜