【发布时间】:2011-01-24 18:55:50
【问题描述】:
我正在尝试使用 Spring Security 以编程方式验证用户登录/密码,因此我需要访问 ProviderManager。我希望它自动注入我的@Controller。
我的代码如下:
import org.springframework.security.authentication.ProviderManager;
// ...
@Controller
public class MyController {
@Autowired
private ProviderManager authenticationManager;
但是当我尝试运行应用程序时,我收到以下错误消息:
No unique bean of type [org.springframework.security.authentication.ProviderManager] is defined:
expected single matching bean but found 2:
[org.springframework.security.authentication.ProviderManager#0, org.springframework.security.authenticationManager]
可能是什么原因或我该如何解决?
我将 Spring Security 3.0.0-RC1 与 Spring 3.0.1 一起使用,并且我没有定义任何 ProviderManager bean。我已经成功使用了:
@Resource
private ProviderManager authenticationManager;
在其他项目中,但 GAE 不支持 javax.annotation.Resource。
【问题讨论】:
标签: google-app-engine spring-security spring