Question

In the following snippet, when I give the @ManagedBean a specific name, userService and authenticationService are not injected. But if I use only @ManagedBean without name, the injection works fine. 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;
Was it helpful?

Solution

when you use @ManagedBean(name="user") try specify the same name for component as well and see if that works.

@Component("user")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top