Spring @Autowired会话bean

时间:2012-12-20 18:04:52

标签: java spring session jsf-2 autowired

我有一个会话作用域用户bean:

@Component
@Scope("session")
public class UserBean {
    private User user;

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}

和地址bean:

@Component
@Scope("session")
public class AddressBean {


    @Autowired
    private UserBean userBean;

    public getUserBean(){
          return userBean;
    }

    public void setUserBean(UserBean userBean){
          this.userBean=userBean;
    }
 }

当我在JSF中调用UserBean时,我可以看到一个对象已被实例化。当我调用AddressBean时... UserBean始终为null并且尚未注入。如何正确连接?

0 个答案:

没有答案