Spring Boot – package javax.persistence does not exist
We migrated the project to Spring Boot 3, and the JPA entity class hits package javax.persistence does not exist
.
java: package javax.persistence does not exist
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
P.S. Tested with Spring Boot 3.1.2
Solution
Spring Boot 3 migrated all Java EE APIs javax.*
to their equivalent Jakarta EE variant jakarta.*
due to the transition from Oracle to the Eclipse Foundation.
To fix this, we should use the Jakarta Persistence (JPA) APIs under the jakarta.persistence
package instead of javax.persistence
.
Spring Boot 3 using Jakarta EE APIs jakarta.*
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
Spring Boot 2.x using Java EE APIs javax.*
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
Many thanks!
is jakarta.persistence.* not within spring-boot-starter-data-jpa ?
if not it is within which dependency?
Thanks Its working your solutions
Thank you so much its working .