The official documentation says
The most fundamental services provided by CDI are as follows:
but i still do not get the difference. Spring for example is DI and we still can access the context in it.
Reading How To Use DI in Java EE 6 by Antonio Goncalves, give us excellent understanding. I will quote one important part of it:
These two specifications are complementary and can’t be used one without the other.
Dependency Injection for Java (aka @Inject) defines a set of annotations (@Inject, @Named, @Provider, @Qualifier, @Scope and @Singleton) mainly used for injection. If you download this JSR (which is actually just Javadoc) and read through it, you will be surprised to see that no semantic is defined (i.e. the injection behaviour is not portable across implementation). This specification is implemented in Spring 3, Guice, and also in Java EE 6 with CDI. You will find the DI annotations in the javax.inject package.
And finally
Contexts and Dependency Injection gives semantic to JSR 330 and adds more features such as context management, events, decorators and enhanced interceptors (AOP).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With