javaspring-bootspring-data-jpajava-module

Error "module not found: jakarta.cdi" when using module-info.java in a Spring boot 3 project


I got the following error when I add the dependency jakarta.transaction to the module-info.java file, as suggested by IntelliJ:

module not found: jakarta.cdi

The module-info.java file dependency is added like this:

module myModule.main {
...
requires jakarta.transaction;
}

The project builds and runs well without the module-info.java file, so I guess all dependencies are well defined at gradle.build file.


Solution

  • The import instruction that triggered the IntelliJ to suggest the dependency was this:

     import jakarta.transaction.Transactional;
    

    In this case, the import should had be from springboot instead :

     import org.springframework.transaction.annotation.Transactional;
    

    I post this answer in case some else fall into this rare problem with no obvious solution.