3

次のスニペットでは、@ManagedBean に特定の名前を付けると、userService と authenticationService は注入されません。しかし、名前なしで @ManagedBean のみを使用すると、インジェクションは正常に機能します。何か案が?

@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;
4

1 に答える 1

2

使用するときは@ManagedBean(name="user")、コンポーネントにも同じ名前を指定して、それが機能するかどうかを確認してください。

@Component("user")
于 2013-03-21T09:39:32.903 に答える