我正在使用Spring 3和Spring Security开发一个项目.我的问题是IoC容器.当我UserDetailsService
为Spring Security-3 编写自己的实现时问题就出现了.我检查了其他问题,但仍无法解决问题.
问题的定义是:
我有两个单独的类(一个是UsersController.java
扩展的@Controller
,ProjectUserDetailsService
哪个扩展@Service
),它使用一个公共对象进行自动装配.但是当对象成功自动装入时UsersController
,它就null
在ProjectUserDetailsService
类中,尽管这个类(ProjectUserDetailsService
)的对象已成功创建(我通过调试验证了这一点).
有什么建议如何解决这个问题?
这里是我的web.xml
,project-servlet.xml
而且project-security.xml
文件和相关的类.
Web.xml`
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Tutorial web application
-
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name>Ecognitio with Spring Security</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/ecognitio-servlet.xml
/WEB-INF/ecognitio-security.xml
</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>tutorial.root</param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener> …
Run Code Online (Sandbox Code Playgroud)