简体   繁体   English

spring vs ejb3-豆类注射有什么不同?

[英]spring vs ejb3 - what is different in beans injection?

is it correct that in spring I can inject my own beans , and in ejb3 I can inject only ejb3 beans ? 在春天我可以注入自己的bean,而在ejb3中只能注入ejb3 bean是正确的吗? if so how can ejb3 be a replacement to Spring? 如果可以,那么ejb3怎么能代替Spring?

In a Java EE environment, you can not only use EJB, but also CDI. 在Java EE环境中,您不仅可以使用EJB,还可以使用CDI。 see How do CDI and EJB compare? 请参阅CDI和EJB如何比较? interact? 相互作用?

Besides the fact that you can use CDI for injecting different types of beans, what do you mean by "ejb3" beans and how those beans are not yours as in case of spring? 除了可以使用CDI注入不同类型的bean以外,“ ejb3” bean是什么意思,以及那些与春季不一样的bean是什么? Spring injects any kind of bean and you do that either by declaring it in XML (old approach) or by specifying an annotation (@Component, @Service, etc.). Spring注入任何类型的bean,您可以通过用XML声明它(旧方法)或通过指定注释(@ Component,@ Service等)来实现。 Which is the case also for EJB3 (you can use @Stateless instead of @Service, just to make an analogy). EJB3也是这种情况(您可以使用@Stateless而不是@Service进行类推)。 So, in JEE environment one can be replaced with the other (from this point of view, Spring has some advantages as it sets the grounds for fast development, providing additional helpers, libraries, frameworks on top of JEE specification - see Spring Data JPA for one). 因此,在JEE环境中,一个可以替换为另一个(从这个角度来看,Spring具有一些优势,因为它为快速开发奠定了基础,并在JEE规范的基础上提供了附加的帮助程序,库和框架-请参阅Spring Data JPA以获取更多信息)。一)。 So, I think is a matter of how you design your application to use one or the other. 因此,我认为这与如何设计应用程序以使用一个或另一个有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM