Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 79029
375
  • 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?
 
Saloon Keeper
Posts: 15438
362
  • 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: 2411
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?
 
Saloon Keeper
Posts: 7573
176
  • 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: 22778
130
Eclipse IDE Spring VI Editor 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic