llms.txt: machine-readable documentation index. Markdown version of this page is also available.

IntelliJ IDEA 2026.3 Help

Contexts and Dependency Injection (CDI)

Jakarta Contexts and Dependency Injection (CDI) is a specification for declarative dependency injection and supporting services.

Enable the Jakarta EE: Contexts and Dependency Injection (CDI) plugin

This functionality relies on the Jakarta EE: Contexts and Dependency Injection (CDI) plugin, which is bundled and enabled in IntelliJ IDEA by default. If the relevant features are not available, make sure that you did not disable the plugin.

  1. Press Ctrl+Alt+S to open settings and then select Plugins.

  2. Find the Jakarta EE: Contexts and Dependency Injection (CDI) plugin and click Enable.

You can enable CDI support when creating a new project or module, or add CDI support to an existing module.

Create a new Jakarta EE project with CDI

  1. Open the New Project wizard:

    • If you are on the Home screen, select Plus sign New | Folder icon Project….

    • If you have another project open, go to File | New | Project.

  2. From the Generators list on the left, select Jakarta EE logo Jakarta EE.

    First step of the Jakarta EE project wizard
  3. Set up the Jakarta EE project settings.

    When you are ready, click Next.

  4. From the Version drop-down list, select the Jakarta EE version you want to use.

  5. From the Dependencies list, select Contexts and Dependency Injection (CDI) and any additional specifications or implementations you want to include in your project.

    Creating new project with CDI support
  6. Click Create.

For more information about creating Jakarta EE projects, such as how to set up an application server, refer to Tutorial: Your first Jakarta EE application.

Add CDI to an existing project

  1. Open the build file in the editor (pom.xml or build.gradle depending on the build tool used in your project).

  2. Add the CDI library, and make sure its version matches the rest of your project:

    Jakarta EE
    <dependency> <groupId>jakarta.enterprise</groupId> <artifactId>jakarta.enterprise.cdi-api</artifactId> <version>4.1.0</version> </dependency>
    Java EE
    <dependency> <groupId>javax.enterprise</groupId> <artifactId>cdi-api</artifactId> <version>2.0.SP1</version> </dependency>
    Jakarta EE
    implementation 'jakarta.enterprise:jakarta.enterprise.cdi-api:4.1.0'
    Java EE
    implementation 'javax.enterprise:cdi-api:2.0.SP1'
    Jakarta EE
    implementation("jakarta.enterprise:jakarta.enterprise.cdi-api:4.1.0")
    Java EE
    implementation("javax.enterprise:cdi-api:2.0.SP1")
  3. Press Ctrl+Shift+O to import the changes.

For more information about working with build tools, refer to Maven or Gradle.

27 October 2026