Not Found javax.persistence in My Spring-boot Project

Java Knowledge Sharing…

Geno Tech
2 min readMay 19, 2023
Photo by Florian Olivo on Unsplash

Here in my case, I tried to import javax.persistence, but It shows, It doesn’t exist. So I found the following solution. I hope. It will help in your case as well. The main reason for this problem is the replacement of javax with jakarta. Therefore the solution is to add the following dependency to your pom.xml.

 <dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
</dependency>

Then you can import javax.persistence without any issue.

import jakarta.persistence.*;

This is the pom.xml and my java class.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo…

--

--

Geno Tech
Geno Tech

Written by Geno Tech

Software Development | Data Science | AI — We write rich & meaningful content on development, technology, digital transformation & life lessons.

No responses yet