How to dependecy inject an EJB3 constructor?

回眸只為那壹抹淺笑 提交于 2019-12-24 12:02:19

问题


According to EJB3 DI documentation it is possible to inject fields and setters. But how to inject a bean constructor ?


回答1:


The EJB specification does not support constructor injection. The EJB programming model only uses the no-arg constructor, and can then perform field or setter method injection after the instance has been constructed.

That said, EJB 3.1 is part of EE 6, which includes CDI. If your EJB module is a CDI BDA (bean deployment archive) because it includes beans.xml, then you can use CDI constructor injection.



来源:https://stackoverflow.com/questions/19932624/how-to-dependecy-inject-an-ejb3-constructor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!