[英]Cannot inject bean into JSF managed bean with specific name in spring
In the following snippet, when I give the @ManagedBean a specific name, userService and authenticationService are not injected. 在下面的代码片段中,当我给@ManagedBean指定一个特定名称时,不会注入userService和authenticationService。 But if I use only @ManagedBean without name, the injection works fine. 但是,如果我只使用没有名字的@ManagedBean,注入工作正常。 Any idea? 任何想法?
@Component
@ManagedBean(name="user") // the injection doesn't work
//@ManagedBean // the injection works
@SessionScoped
public class UserManagedBean implements Serializable {
// Spring User Service is injected...
@Autowired
UserService userService;
@Autowired
private AuthenticationService authenticationService;
当你使用@ManagedBean(name="user")
尝试为组件指定相同的名称,看看是否有效。
@Component("user")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.