我一直收到一条消息:“org.springframework.beans.factory.NoSuchBeanDeFinitionException:没有定义名为’userDetailsService’的bean”,即使bean被定义为UserDetailsServiceImpl类中的服务.如:
@Service(value="userDetailsService")
public class UserDetailsServiceImpl implements UserDetailsService{
我正在使用最新的Spring和Spring Security.
我不确定我做错了什么.我正在粘贴我的spring xml文件的配置. spring-security.xml显示它在使用组件扫描时可以从servlet-context.xml中找到bean.
谢谢
org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.filterChains': Cannot resolve reference to bean org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot resolve reference to bean org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean org.springframework.security.authentication.ProviderManager#0' while setting bean property authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.authentication.ProviderManager#0': Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerfactorybean#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.config.authentication.AuthenticationManagerfactorybean#0': factorybean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.authenticationManager': Cannot resolve reference to bean org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'userDetailsService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.NoSuchBeanDeFinitionException: No bean named 'userDetailsService' is defined
ecurity"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
sspath*:servlet-context.xml"/>
ecurity secured-annotations="enabled"> ecurity>
fig="true" >