我尝试注入一个applicationScoped Bean。 我发现了类似的主题在JSF2 ApplicationScope bean instantiation time?和 Get JSF managed bean by name in any Servlet related classJava Inject Applicationscope Bean
随着faces上下文JSF的方式,所有的罚款(WebsitesController是AppScoped):
FacesContext context = FacesContext.getCurrentInstance();
WebsiteController websitesController = context.getApplication().evaluateExpressionGet(context, "#{websitesController}", WebsitesController.class);
随着两个溢出线程这是行不通的注射。我的代码:
@ManagedBean(eager=true)
@ApplicationScoped
public class WebsitesController implements Serializable {
...}
,现在我想
@ManagedBean(name = "shopController")
@ViewScoped
public class ShopController {
{Injection-Statement}
private WebsitesController websitesController;
我尝试下面的语句:
@ManagedProperty("#{websitesController}")
@Inject
@EJB
什么我的错吗?