I'm testing Java 9 with a project which requires JPA (javax.persistence.*
classes). When I add the module-info.java
and declare my module, all classes under javax.persistece
package become unavailable.
I searched a lot, but I couldn't find the module to require to use JPA in a Java 9 module project.
UPDATE As Alan suggested, I ran
$ jar --describe-module --file=javax.persistence-api-2.2.jar
No module descriptor found. Derived automatic module.
java.persistence@2.2 automatic
requires java.base mandated
contains javax.persistence
contains javax.persistence.criteria
contains javax.persistence.metamodel
contains javax.persistence.spi
But still with this module-info.java
module my.module {
requires java.persistence;
}
I get "module-info.java:[3,18] module not found: java.persistence".
UPDATE 2 This is my project structure:
.
├── pom.xml
└── src
├── main
│ ├── java
│ │ ├── my
│ │ │ └── module
│ │ │ └── MyBean.java
│ │ └── module-info.java
│ └── resources
└── test
├── java
└── resources
The pom.xml
has the javax.persistence-api
dependency.
Testing repo: https://github.com/heruan/java9-jpa