Java - Dependency Injection (DI)

> Procedural Languages > Java

1 - About

Dependency injection in Java.

This page is about injection of a java dependency in a class.


3 - Library

4 - Specification

4.1 - JSR 330: Dependency Injection for Java

The standard Java annotations for describing the dependencies of a class are defined in the Java Specification Request 330 (JSR330).

This specification describes the following annotations:

  • @Inject
  • and @Named

4.2 - JSR-299 - Contexts and Dependency Injection (CDI)

Contexts and Dependency Injection (CDI) is specified by JSR-299

Dependency injection is when the EJB container automatically supplies (or injects) a variable or setter method in the bean file with a reference to another EJB or resource or another environment entry in the bean's context.

Bean files supports dependency injection.