What is the relationship between Spring and javax.enterprise.inject?

I read the Wikipedia article on Java EE application servers here:

http://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition#Java_EE_5_certified

It says that 2 APIs that implement Java App Services:

javax.enterprise.inject javax.enterprise.context 

Both relate to the application context and dependency injection of JSR-299. I have never heard of these APIs before. Does Spring use these APIs? Would it be important if they did this?

+4
source share
2 answers
  • JSR-330 defines a set of annotations ( javax.inject ) that should be used in different dependency injection structures. The spec was done by Rod Johnson (from Spring) and Bob Lee from (Google Guice)
  • (partially) due to specs, spring and guice support this set of annotations

This is the part of JavaEE that spring uses.

The same kit is used by JSR-299, which is led by JBoss Gavin King. However, JSR-299 (also known as CDI) uses javax.enterprise.inejct/context and represents a completely new dependency injection framework. It is based on the ideas of spring, guice and seam, but is formally defined as JSR and is designed to cover many corner cases, as well as seamless integration with other parts of JavaEE.

JSR-299 defines both an API and an SPI so that specific implementations can be developed. Current implementations of JBoss Weld , Apache OpenWebBeans, and Resin CanDI .

So, to answer your question - there is no direct connection between javax.enterprise.inject and spring.

+3
source

Spring supports JSR-330 @Inject - it can be used instead of @Autowired (except that it does not have the required property).

You also need to have a JSR 330 jar in the classpath.

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-autowired-annotation

+2
source

Source: https://habr.com/ru/post/1312052/


All Articles