我需要在ContextCacheRefresh web服务上注入initApplicationContext bean,但是不成功,initApplicationContext的值总是null。请问有人知道如何解决吗?
@ManagedBean(name = "initApplicationContext", eager = true)
@ApplicationScoped
public class InitApplicationContext {
.......................
}
和网络服务
@Path("/serviceContext")
public class ContextCacheRefresh {
@ManagedProperty(value = "#{initApplicationContext}")
private InitApplicationContext initApplicationContext;
@GET
@Path("/refreshContext")
public Response refreshUserListOn(@QueryParam("param") String param
) { ......
@Inject
。 - kolossus@Named
注解替代@ManagedBean
,并使用@Inject
将其注入到您的Restful服务中。管理Bean仅是JSF页面的控制器。 - Everv0id