DEV Community

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

Posted on

1

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!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay