gpt4 book ai didi

dependency-injection - CDI 可以注入(inject)我的 Bean 的远程实例吗?

转载 作者:行者123 更新时间:2023-12-04 08:20:10 24 4
gpt4 key购买 nike

CDI 可以在我的远程 EJB 客户端中注入(inject) EJB 引用吗?

实际上,我有一个 JUnit 测试用例,它在我的系统上本地运行并访问在独立 JBoss AS 上运行的 EJB。我目前正在使用 JNDI 访问 bean 的远程业务接口(interface)并对其进行测试。

我想知道,如果@Inject 可以在这里帮助我将我的 EJB 实例直接注入(inject)我的测试用例,这样我就可以避免 JNDI 查找并仍然访问 EJB?

最佳答案

不便携。来自 CDI 规范:

The unrestricted set of bean types for a session bean contains all local interfaces of the bean and their superinterfaces. If the session bean has a bean class local view, the unrestricted set of bean types contains the bean class and all superclasses. In addition, java.lang.Object is a bean type of every session bean.

Remote interfaces are not included in the set of bean types.

关于dependency-injection - CDI 可以注入(inject)我的 Bean 的远程实例吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6381123/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com