我的 @Startup 单例未在 JavaEE 应用程序中启动
我得到了以下单例代码:
@javax.ejb.Singleton
@javax.ejb.Startup
public class SingletonWhichIsSupposedToStart {
@PostConstruct
public void ready(){
//there is a breakpoint on the next line
System.out.println("singleton ready");
}
}
但是当我以调试模式(在 Glassfish3 上)启动应用程序时,既没有打印“单例就绪”,也没有触发断点。有什么建议吗?
编辑:似乎该类已部署,并且可以注入,但生命周期方法 @PostConstruct 被忽略。
I got the following Singleton code:
@javax.ejb.Singleton
@javax.ejb.Startup
public class SingletonWhichIsSupposedToStart {
@PostConstruct
public void ready(){
//there is a breakpoint on the next line
System.out.println("singleton ready");
}
}
But when I start the application in debug mode (on Glassfish3), nor the 'singleton ready' is printed, nor the breakpoint is triggered. Any suggestions?
EDIT: Seems that the class is deployed, and can be injected, but the lifecycle method @PostConstruct is ignored.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论