DEV Community

Cover image for Spring Boot 3 – package javax.persistence does not exist
KenjiGoh
KenjiGoh

Posted on

Spring Boot 3 – package javax.persistence does not exist

When migrating from Spring Boot 2 to Spring Boot 3, one might face this error:

The import javax.persistence cannot be resolvedJava(268435846)
Enter fullscreen mode Exit fullscreen mode

This is due to this Transition from Java EE to Jakarta EE

Spring Boot 2.x using Java EE APIs javax.*

java: package javax.persistence does not exist

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;  
Enter fullscreen mode Exit fullscreen mode

To fix this, we can just update all javax to jakarta.

Spring Boot 3 using Jakarta EE APIs jakarta.*

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id; 
Enter fullscreen mode Exit fullscreen mode

Thanks!

Top comments (1)

Collapse
 
dayosoh profile image
dayosoh

hey thats helpful!