JSF Named Bean, Eager application scoped (aka @ManagedBean(eager=true) )
问题 Is there any way to initialize Named Bean annotaded by javax.inject.Named / javax.enterprise.context.ApplicationScoped like @ManagedBean(eager=true) from javax.faces package? @Named @ApplicationScoped public Mail() { ... } I want to load this class when application starts, not when webapplication refers to this bean. ps. JSF 2.1 Bean Injected by Glassfish 3.1 回答1: You can create a CDI extension that has the @Observes AfterBeanDiscovery parameter on one of his methods. There you can