我的代码:
@Path("/actors")
public class MainController {
@EJB
private ActorDaoLocal actorDao;
}
@Local
public interface ActorDaoLocal {
//some stuff here
}
@Stateless
public class ActorDao implements ActorDaoLocal {
@PersistenceContext
private EntityManager em ;
//some stuff here
}
@ManagedBean(name = "ActorBean")
@ApplicationScoped
public class ActorBean {
@EJB
private ActorDaoLocal usersDao;
}
当我尝试在actorDao
类中使用MainController
时,它为空。为什么以及如何解决它?我也尝试使用ActorBean
对象,但它也是null。