【发布时间】:2011-12-05 04:30:24
【问题描述】:
我尝试注入一个 applicationScoped Bean。 我在JSF2 ApplicationScope bean instantiation time? 和 Get JSF managed bean by name in any Servlet related class
在 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
我的错是什么?
【问题讨论】:
标签: jakarta-ee scope ejb javabeans inject