Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在 Web 应用程序中@Inject使用EJB?@Remote我在 Glassfish 5 上运行,并且正在部署 EAR (EJB + WAR)。
@Inject
@Remote
@Local当我用CDI注释 EJB 接口时,@Remote没有。 可能是什么原因?
@Local
顺便说一句,使用@EJB而不是@Inject完美地工作,但我要解决这个@Inject问题。
@EJB
CDI 无法解析远程 ejb bean。根据规格3.2.2
3.2.2
会话 bean 的不受限制的 bean 类型集包含 bean 的所有本地接口及其超接口。如果会话 bean 具有无接口视图,则 bean 声明会话 bean 41 种类型的不受限制的集合包含 bean 类和所有超类。此外,java.lang.Object 是每个会话 bean 的 bean 类型。远程接口不包括在 bean 类型集中。
如果您必须使用 CDI 注入而不是@EJB