Spring 和 javax.enterprise.inject 之间有什么关系?
我正在阅读一篇关于 Java EE 应用程序服务器的维基百科文章:
http://en.wikipedia .org/wiki/Java_Platform,_Enterprise_Edition#Java_EE_5_certified
它说 Java 应用服务实现的 2 个 API 是:
javax.enterprise.inject
javax.enterprise.context
它们都与应用程序上下文和依赖项注入 JSR-299 相关。我以前从未听说过这些 API。 Spring 实现了这些 API 吗?如果他们这样做的话,对任何人都会有影响吗?
I was reading a Wikipedia article about Java EE application servers here:
http://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition#Java_EE_5_certified
It says that 2 APIs that Java App Services implement are:
javax.enterprise.inject
javax.enterprise.context
These both relate to application context and dependency injection JSR-299. I had never heard of these APIs before. Does Spring implement these APIs? Would it matter to anyone if they did?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
javax.inject
)。该规范由 Rod Johnson(来自 Spring)和 Bob Lea(来自 Google Guice)(部分)领导,这是 spring 使用的 JavaEE 部分。
由 JBoss 的 Gavin King 领导的 JSR-299 使用相同的集合。然而,JSR-299(也称为 CDI)使用 javax.enterprise.inejct/context,并且是一个全新的依赖项注入框架。它基于 spring、guice 和 seam 的思想,但被正式指定为 JSR,旨在覆盖许多极端情况以及与其他 JavaEE 部分的平滑集成。
JSR-299 定义了 API 和 SPI,以便可以开发具体的实现。当前的实现是 JBoss Weld、Apache OpenWebBeans 和 树脂 CanDI。
因此,回答你的问题 - javax.enterprise.inject 和 spring 之间没有直接关系。
javax.inject
) that are to be used across different dependency injection frameworks. The specification was lead by Rod Johnson (from Spring), and Bob Lea from (Google Guice)This is the part of JavaEE that is used by spring.
The same set is used by JSR-299, which is lead by Gavin King from JBoss. However, JSR-299 (also known as CDI) uses
javax.enterprise.inejct/context
and is a whole new dependency-injection framework. It is based on ideas of spring, guice and seam, but is specified formally as a JSR and aims at covering many corner cases as well as smooth integration with other JavaEE parts.JSR-299 defines both an API and SPI so that concrete implementations can be developed. Current implementations are JBoss Weld, Apache OpenWebBeans and Resin CanDI.
So, to answer your question - there is no direct relation between
javax.enterprise.inject
and spring.Spring 确实支持 JSR-330 的 @Inject - 它可以用来代替 @Autowired (除了它没有
required
属性)。您还需要将 JSR 330 jar 放在类路径中。
http: //static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-autowired-annotation
Spring does support JSR-330's @Inject - it can be used in place of @Autowired (except that it doesn't have a
required
property).You also need to have the JSR 330 jar on the classpath.
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-autowired-annotation