Exploring Contexts and dependency injection

CDI is Java EE's attempt at bringing DI into Java EE. While not as fully-fledged as Spring, CDI aims to standardize the basics of how DI is done. Spring supports the standard annotations defined in JSR-330. For the most part, these annotations are treated the same way as Spring annotations.

Before we can use CDI, we will need to ensure that we have dependencies for CDI jars included. Here's the code snippet:

    <dependency>       <groupId>javax.inject</groupId>       <artifactId>javax.inject</artifactId>       <version>1</version>     </dependency>

In this table, let's compare the CDI annotations with the annotations provided by Spring Framework. It should be noted that @Value, @Required, and @Lazy Spring annotations ...

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.