向 EJB 添加依赖项
我想添加对 EJB 的依赖项。我如何使用 Spring 来做到这一点?依赖对象是通用服务对象。根据下面的代码,我想连接 myDependency 而不必使用“new”。 EJB 在 weblogic 中运行。
@Stateless(mappedName = "MyBean")
public class MyBean implements MyBeanRemote, MyBeanLocal {
@EJB(name = "MyOtherBean")
private MyOtherBean myOtherBean;
private MyDependency myDependency;
...
}
I want to add a dependency to an EJB. How do I do this using Spring? The dependent object is a general service object. Based on code below I want to wire myDependency without having to use 'new'.
The EJB runs in weblogic.
@Stateless(mappedName = "MyBean")
public class MyBean implements MyBeanRemote, MyBeanLocal {
@EJB(name = "MyOtherBean")
private MyOtherBean myOtherBean;
private MyDependency myDependency;
...
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这在 Spring文档:
然而,无状态 EJB 和 Spring bean 提供了或多或少相同的可能性。将它们混合在一起似乎是不必要的复杂性。
This is well described in the Spring documentation:
Stateless EJBs and Spring beans, however, offer more or less the same possibilities. Mixing them together seems like unnecessary complexity.