• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

The import javax.persistence cannot be resolved

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i can't resolve "message": "The import javax.persistence cannot be resolved",
i use ubuntu, jdk Temurin17 , maven version 3.9  <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

i try gradle i have the same pb could you please help me.
Best regards
 
Marshal
Posts: 80230
424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please avoid abbreviations like, “pb,” which is not clear to all readers.

We can only help if we have the full details. Which module is that package in? It appears not to be in Java21SE. Do you have Java® installations? Do you have EE classes installed anywhere?
 
Bartender
Posts: 15737
368
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You probably just need to rename your imports to jakarta.persistence.
 
snow Atlas
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
thanks for your response, but i have an other project with jdk temurin 17 and  javax.persistence works, i don't understande why?
Best resgards
 
Bartender
Posts: 2445
13
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it because the other project is using Spring Boot 2 and it accepts java.persistence?
 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

snow Atlas wrote:i have an other project with jdk temurin 17 and  javax.persistence works, i don't understande why?


A different project will have different dependencies, and consequently different imports can be resolved.
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javax.persistence versus jakarta.persistence has nothing to do with the JDK itself, it's indeed the dependencies that determine which of the two you need. Spring Boot 2.x used javax.persistence, but in Spring Boot 3 they moved to jakarta.persistence. This is basically just a newer version of the same thing, but due to licensing (or something like that) the javax. package prefix could no longer be used. The javax. package prefix is owned by Oracle, and Java EE is now no longer owned by Oracle but renamed to Jakarta EE.
 
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic