Worked for me by changing Hibernate to version 5.6.9.Final (or any higher 5.6.x):
<hibernate.version>5.6.9.Final</hibernate.version>
I solved the error by changing my javax.persistence package to jakarta.persistence. So my class Task ended up like this:
package com.taskManager.Entities;
import java.time.LocalDateTime;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
@Entity(name = "task")
public class Task {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@Column(nullable = false)
private String name;
@ManyToOne(fetch = FetchType.LAZY)
//@JoinColumn(name = "user_id")
//private User user;
private String description;
private LocalDateTime date;
public Task(Long id, String name, String description, LocalDateTime date) {
super();
this.id = id;
this.name = name;
this.description = description;
this.date = date;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public LocalDateTime getDate() {
return date;
}
public void setDate(LocalDateTime date) {
this.date = date;
}
public Task(String name, String description, LocalDateTime date) {
super();
this.name = name;
this.description = description;
this.date = date;
}
}
I also had to remove the hibernate, jakarta, and javax dependencies in my pom.xml:
4.0.0
org.springframework.boot
spring-boot-starter-parent
3.0.4
com.taskManager
Task-Manager
0.0.1-SNAPSHOT
Task-Manager
Application for managing different tasks
17
org.springframework.boot
spring-boot-starter-security
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-devtools
runtime
true
org.springframework.boot
spring-boot-starter-test
test
org.springframework.security
spring-security-test
test
org.glassfish.jaxb
jaxb-runtime
3.0.0
com.mysql
mysql-connector-j
runtime
org.springframework.boot
spring-boot-starter-data-jpa
org.springframework.boot
spring-boot-maven-plugin
The error message "Class org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider does not implement the requested interface jakarta.persistence.spi.PersistenceProvider" typically occurs when there's a compatibility issue between Spring ORM and the Jakarta Persistence API (formerly known as Java Persistence API or JPA).
After applying the above steps and ensuring compatibility between Spring ORM and Jakarta Persistence API, rebuild your application and test to verify that the error no longer occurs.