问题
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