Tag: springjavaconfiguration

如何在自定义filter中使用Javaconfiguration注入AuthenticationManager

我正在使用Spring Security 3.2和Spring 4.0.1 我正在把XMLconfiguration转换成Javaconfiguration。 当我在Filter中使用@Autowired注解AuthenticationManager时,我收到一个exception Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.security.authentication.AuthenticationManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} 我已经尝试注入AuthenticationManagerFactoryBean但也失败了一个类似的exception。 这是我正在从事的XMLconfiguration <?xml version="1.0" encoding="UTF-8"?> <beans …> <security:authentication-manager id="authenticationManager"> <security:authentication-provider user-service-ref="userDao"> <security:password-encoder ref="passwordEncoder"/> </security:authentication-provider> </security:authentication-manager> <security:http realm="Protected API" use-expressions="true" auto-config="false" create-session="stateless" […]