无法在Spring Security中识别身份validation提供程序user-service-ref

我正在我的项目中实现spring security

在我的DAO类中,我定义了loadUserByUsername

我的class级就像

UserDAOImpl.java

@Repository public class UserDAOImpl { public UserDetails loadUserByUsername(String name)throws UsernameNotFoundException { //implementation } } 

在Spring-security.xml中

     

但是当我运行程序时,我收到一个错误

 Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'UserDAOImpl' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'UserDAOImpl' is defined 

任何人都可以帮我解决这个问题吗?

通常,扫描组件的bean是以小写字符开头的,因此bean将作为userDAOImpl (而不是UserDAOImpl )存在于应用程序上下文中

spring-security.xml片段更改为

     

希望这对你有用。

嗯……让它运转起来。

移动

   

从dispatcher-servlet到application-context.xml

类名称上的@Service(“userDAOImpl”)注释

有人会关心为什么它开始工作?