How to correct the classpath of spring boot application so that it contains a single, compatible version of...
I am trying to add a participantRepository interface (which implements CrudRepository) to my spring boot application. But the basic code for this interface gives an error when it is run saying that the classpath of the application must be corrected. How can I do this and is there another modification I can do to run the code correctly?
//Participant class
package com.example.spring2.participants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.List;
@Entity
public class Participant {
@Id
private String name;
private int age;
private String job;
@Autowired
private ParticipentService participentService;
public Participant() {
}
public Participant(String name, int age, String job) {
this.name = name;
this.age = age;
this.job = job;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
}
//ParticipantController class
package com.example.spring2.participants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
public class ParticipantController {
@Autowired
private ParticipentService participentService;
@RequestMapping("/people")
public List<Participant> viewPeople(){
return participentService.getParticipants();
}
@RequestMapping("/people/{name}")
public Participant getAParticipant(@PathVariable String name) {
return participentService.getAParticipant(name);
}
@RequestMapping(method = RequestMethod.POST, value = "/people")
public void addParticipant(@RequestBody Participant participant){
participentService.addParticipant(participant);
}
@RequestMapping(method = RequestMethod.PUT, value = "/people/{name}")
public void updateParticipant(@RequestBody Participant participant, @PathVariable String name) {
participentService.updateParticipant(participant, name);
}
@RequestMapping(method = RequestMethod.DELETE, value = "/people/{name}")
public void deleteParticipant(@PathVariable String name) {
participentService.deleteParticipant(name);
}
}
//ParticipantService class
package com.example.spring2.participants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
@Service
public class ParticipentService {
private List<Participant> participantList = Arrays.asList(
new Participant("yasas", 23, "Student"),
new Participant("anu", 28, "accountant"),
new Participant("banu", 26, "teacher")
);
@Autowired
private ParticipantRepository participantRepositoty;
public List<Participant> getParticipants(){
return participantList;
}
public void addParticipant(Participant participant) {
participantList.add(participant);
}
public void updateParticipant(Participant participant, String name ){
for (int i=0; i < participantList.size(); i++){
Participant p = participantList.get(i);
if (p.getName().equals(name)){
participantList.set(i, participant);
return;
}
}
}
public void deleteParticipant(String name ){
for (int i=0; i < participantList.size(); i++){
Participant p = participantList.get(i);
if (p.getName().equals(name)){
participantList.remove(p);
}
}
}
public Participant getAParticipant(String name) {
for (int i=0; i < participantList.size(); i++){
Participant p = participantList.get(i);
if (p.getName().equals(name)){
return p;
}
}
return null;
}
}
//POM.xml
<?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 http://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>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>spring2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I expected the server to be started when the application is run. But it gives following error.
Description:
An attempt was made to call the method javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType; but it does not exist. Its class, javax.persistence.PersistenceContext, is available from the following locations:
jar:file:/C:/Users/Asus/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.jar!/javax/persistence/PersistenceContext.class
jar:file:/C:/Users/Asus/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar!/javax/persistence/PersistenceContext.class
It was loaded from the following location:
file:/C:/Users/Asus/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.persistence.PersistenceContext
java spring-boot spring-data-jpa
add a comment |
I am trying to add a participantRepository interface (which implements CrudRepository) to my spring boot application. But the basic code for this interface gives an error when it is run saying that the classpath of the application must be corrected. How can I do this and is there another modification I can do to run the code correctly?
//Participant class
package com.example.spring2.participants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.List;
@Entity
public class Participant {
@Id
private String name;
private int age;
private String job;
@Autowired
private ParticipentService participentService;
public Participant() {
}
public Participant(String name, int age, String job) {
this.name = name;
this.age = age;
this.job = job;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
}
//ParticipantController class
package com.example.spring2.participants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
public class ParticipantController {
@Autowired
private ParticipentService participentService;
@RequestMapping("/people")
public List<Participant> viewPeople(){
return participentService.getParticipants();
}
@RequestMapping("/people/{name}")
public Participant getAParticipant(@PathVariable String name) {
return participentService.getAParticipant(name);
}
@RequestMapping(method = RequestMethod.POST, value = "/people")
public void addParticipant(@RequestBody Participant participant){
participentService.addParticipant(participant);
}
@RequestMapping(method = RequestMethod.PUT, value = "/people/{name}")
public void updateParticipant(@RequestBody Participant participant, @PathVariable String name) {
participentService.updateParticipant(participant, name);
}
@RequestMapping(method = RequestMethod.DELETE, value = "/people/{name}")
public void deleteParticipant(@PathVariable String name) {
participentService.deleteParticipant(name);
}
}
//ParticipantService class
package com.example.spring2.participants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
@Service
public class ParticipentService {
private List<Participant> participantList = Arrays.asList(
new Participant("yasas", 23, "Student"),
new Participant("anu", 28, "accountant"),
new Participant("banu", 26, "teacher")
);
@Autowired
private ParticipantRepository participantRepositoty;
public List<Participant> getParticipants(){
return participantList;
}
public void addParticipant(Participant participant) {
participantList.add(participant);
}
public void updateParticipant(Participant participant, String name ){
for (int i=0; i < participantList.size(); i++){
Participant p = participantList.get(i);
if (p.getName().equals(name)){
participantList.set(i, participant);
return;
}
}
}
public void deleteParticipant(String name ){
for (int i=0; i < participantList.size(); i++){
Participant p = participantList.get(i);
if (p.getName().equals(name)){
participantList.remove(p);
}
}
}
public Participant getAParticipant(String name) {
for (int i=0; i < participantList.size(); i++){
Participant p = participantList.get(i);
if (p.getName().equals(name)){
return p;
}
}
return null;
}
}
//POM.xml
<?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 http://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>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>spring2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I expected the server to be started when the application is run. But it gives following error.
Description:
An attempt was made to call the method javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType; but it does not exist. Its class, javax.persistence.PersistenceContext, is available from the following locations:
jar:file:/C:/Users/Asus/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.jar!/javax/persistence/PersistenceContext.class
jar:file:/C:/Users/Asus/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar!/javax/persistence/PersistenceContext.class
It was loaded from the following location:
file:/C:/Users/Asus/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.persistence.PersistenceContext
java spring-boot spring-data-jpa
Check properties and dependency files from github.com/dineshbhagat/spring-boot-web-jpa as reference
– dkb
Dec 29 '18 at 11:49
Also delete files from:C:/Users/Asus/.m2/repository/org/hibernate/
folder and retry building project. works in some of the cases.
– dkb
Dec 29 '18 at 11:51
Your code looks huge - did you make sure it's a minimal example?
– Nino Filiu
Dec 29 '18 at 11:55
add a comment |
I am trying to add a participantRepository interface (which implements CrudRepository) to my spring boot application. But the basic code for this interface gives an error when it is run saying that the classpath of the application must be corrected. How can I do this and is there another modification I can do to run the code correctly?
//Participant class
package com.example.spring2.participants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.List;
@Entity
public class Participant {
@Id
private String name;
private int age;
private String job;
@Autowired
private ParticipentService participentService;
public Participant() {
}
public Participant(String name, int age, String job) {
this.name = name;
this.age = age;
this.job = job;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
}
//ParticipantController class
package com.example.spring2.participants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
public class ParticipantController {
@Autowired
private ParticipentService participentService;
@RequestMapping("/people")
public List<Participant> viewPeople(){
return participentService.getParticipants();
}
@RequestMapping("/people/{name}")
public Participant getAParticipant(@PathVariable String name) {
return participentService.getAParticipant(name);
}
@RequestMapping(method = RequestMethod.POST, value = "/people")
public void addParticipant(@RequestBody Participant participant){
participentService.addParticipant(participant);
}
@RequestMapping(method = RequestMethod.PUT, value = "/people/{name}")
public void updateParticipant(@RequestBody Participant participant, @PathVariable String name) {
participentService.updateParticipant(participant, name);
}
@RequestMapping(method = RequestMethod.DELETE, value = "/people/{name}")
public void deleteParticipant(@PathVariable String name) {
participentService.deleteParticipant(name);
}
}
//ParticipantService class
package com.example.spring2.participants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
@Service
public class ParticipentService {
private List<Participant> participantList = Arrays.asList(
new Participant("yasas", 23, "Student"),
new Participant("anu", 28, "accountant"),
new Participant("banu", 26, "teacher")
);
@Autowired
private ParticipantRepository participantRepositoty;
public List<Participant> getParticipants(){
return participantList;
}
public void addParticipant(Participant participant) {
participantList.add(participant);
}
public void updateParticipant(Participant participant, String name ){
for (int i=0; i < participantList.size(); i++){
Participant p = participantList.get(i);
if (p.getName().equals(name)){
participantList.set(i, participant);
return;
}
}
}
public void deleteParticipant(String name ){
for (int i=0; i < participantList.size(); i++){
Participant p = participantList.get(i);
if (p.getName().equals(name)){
participantList.remove(p);
}
}
}
public Participant getAParticipant(String name) {
for (int i=0; i < participantList.size(); i++){
Participant p = participantList.get(i);
if (p.getName().equals(name)){
return p;
}
}
return null;
}
}
//POM.xml
<?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 http://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>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>spring2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I expected the server to be started when the application is run. But it gives following error.
Description:
An attempt was made to call the method javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType; but it does not exist. Its class, javax.persistence.PersistenceContext, is available from the following locations:
jar:file:/C:/Users/Asus/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.jar!/javax/persistence/PersistenceContext.class
jar:file:/C:/Users/Asus/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar!/javax/persistence/PersistenceContext.class
It was loaded from the following location:
file:/C:/Users/Asus/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.persistence.PersistenceContext
java spring-boot spring-data-jpa
I am trying to add a participantRepository interface (which implements CrudRepository) to my spring boot application. But the basic code for this interface gives an error when it is run saying that the classpath of the application must be corrected. How can I do this and is there another modification I can do to run the code correctly?
//Participant class
package com.example.spring2.participants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.List;
@Entity
public class Participant {
@Id
private String name;
private int age;
private String job;
@Autowired
private ParticipentService participentService;
public Participant() {
}
public Participant(String name, int age, String job) {
this.name = name;
this.age = age;
this.job = job;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
}
//ParticipantController class
package com.example.spring2.participants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
public class ParticipantController {
@Autowired
private ParticipentService participentService;
@RequestMapping("/people")
public List<Participant> viewPeople(){
return participentService.getParticipants();
}
@RequestMapping("/people/{name}")
public Participant getAParticipant(@PathVariable String name) {
return participentService.getAParticipant(name);
}
@RequestMapping(method = RequestMethod.POST, value = "/people")
public void addParticipant(@RequestBody Participant participant){
participentService.addParticipant(participant);
}
@RequestMapping(method = RequestMethod.PUT, value = "/people/{name}")
public void updateParticipant(@RequestBody Participant participant, @PathVariable String name) {
participentService.updateParticipant(participant, name);
}
@RequestMapping(method = RequestMethod.DELETE, value = "/people/{name}")
public void deleteParticipant(@PathVariable String name) {
participentService.deleteParticipant(name);
}
}
//ParticipantService class
package com.example.spring2.participants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
@Service
public class ParticipentService {
private List<Participant> participantList = Arrays.asList(
new Participant("yasas", 23, "Student"),
new Participant("anu", 28, "accountant"),
new Participant("banu", 26, "teacher")
);
@Autowired
private ParticipantRepository participantRepositoty;
public List<Participant> getParticipants(){
return participantList;
}
public void addParticipant(Participant participant) {
participantList.add(participant);
}
public void updateParticipant(Participant participant, String name ){
for (int i=0; i < participantList.size(); i++){
Participant p = participantList.get(i);
if (p.getName().equals(name)){
participantList.set(i, participant);
return;
}
}
}
public void deleteParticipant(String name ){
for (int i=0; i < participantList.size(); i++){
Participant p = participantList.get(i);
if (p.getName().equals(name)){
participantList.remove(p);
}
}
}
public Participant getAParticipant(String name) {
for (int i=0; i < participantList.size(); i++){
Participant p = participantList.get(i);
if (p.getName().equals(name)){
return p;
}
}
return null;
}
}
//POM.xml
<?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 http://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>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>spring2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring2</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I expected the server to be started when the application is run. But it gives following error.
Description:
An attempt was made to call the method javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType; but it does not exist. Its class, javax.persistence.PersistenceContext, is available from the following locations:
jar:file:/C:/Users/Asus/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.jar!/javax/persistence/PersistenceContext.class
jar:file:/C:/Users/Asus/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar!/javax/persistence/PersistenceContext.class
It was loaded from the following location:
file:/C:/Users/Asus/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of javax.persistence.PersistenceContext
java spring-boot spring-data-jpa
java spring-boot spring-data-jpa
asked Dec 29 '18 at 11:44
IsuruIsuru
1
1
Check properties and dependency files from github.com/dineshbhagat/spring-boot-web-jpa as reference
– dkb
Dec 29 '18 at 11:49
Also delete files from:C:/Users/Asus/.m2/repository/org/hibernate/
folder and retry building project. works in some of the cases.
– dkb
Dec 29 '18 at 11:51
Your code looks huge - did you make sure it's a minimal example?
– Nino Filiu
Dec 29 '18 at 11:55
add a comment |
Check properties and dependency files from github.com/dineshbhagat/spring-boot-web-jpa as reference
– dkb
Dec 29 '18 at 11:49
Also delete files from:C:/Users/Asus/.m2/repository/org/hibernate/
folder and retry building project. works in some of the cases.
– dkb
Dec 29 '18 at 11:51
Your code looks huge - did you make sure it's a minimal example?
– Nino Filiu
Dec 29 '18 at 11:55
Check properties and dependency files from github.com/dineshbhagat/spring-boot-web-jpa as reference
– dkb
Dec 29 '18 at 11:49
Check properties and dependency files from github.com/dineshbhagat/spring-boot-web-jpa as reference
– dkb
Dec 29 '18 at 11:49
Also delete files from:
C:/Users/Asus/.m2/repository/org/hibernate/
folder and retry building project. works in some of the cases.– dkb
Dec 29 '18 at 11:51
Also delete files from:
C:/Users/Asus/.m2/repository/org/hibernate/
folder and retry building project. works in some of the cases.– dkb
Dec 29 '18 at 11:51
Your code looks huge - did you make sure it's a minimal example?
– Nino Filiu
Dec 29 '18 at 11:55
Your code looks huge - did you make sure it's a minimal example?
– Nino Filiu
Dec 29 '18 at 11:55
add a comment |
1 Answer
1
active
oldest
votes
first remove in your repository maven the directory hibernate and then make a maven clean install
to reimport correctly your dependencies.
if it still doesn't fix your problem make a maven tree:dependency
to detect what dependence import the hibernate-jpa-2.0-api and exclude it in your pom
I tried maven clean install. I did not work. Then I removed the dependency which imports hibernate-jpa-2.0-api from pom. But now I'm getting this error. Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]
– Isuru
Jan 1 at 7:01
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53969204%2fhow-to-correct-the-classpath-of-spring-boot-application-so-that-it-contains-a-si%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
first remove in your repository maven the directory hibernate and then make a maven clean install
to reimport correctly your dependencies.
if it still doesn't fix your problem make a maven tree:dependency
to detect what dependence import the hibernate-jpa-2.0-api and exclude it in your pom
I tried maven clean install. I did not work. Then I removed the dependency which imports hibernate-jpa-2.0-api from pom. But now I'm getting this error. Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]
– Isuru
Jan 1 at 7:01
add a comment |
first remove in your repository maven the directory hibernate and then make a maven clean install
to reimport correctly your dependencies.
if it still doesn't fix your problem make a maven tree:dependency
to detect what dependence import the hibernate-jpa-2.0-api and exclude it in your pom
I tried maven clean install. I did not work. Then I removed the dependency which imports hibernate-jpa-2.0-api from pom. But now I'm getting this error. Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]
– Isuru
Jan 1 at 7:01
add a comment |
first remove in your repository maven the directory hibernate and then make a maven clean install
to reimport correctly your dependencies.
if it still doesn't fix your problem make a maven tree:dependency
to detect what dependence import the hibernate-jpa-2.0-api and exclude it in your pom
first remove in your repository maven the directory hibernate and then make a maven clean install
to reimport correctly your dependencies.
if it still doesn't fix your problem make a maven tree:dependency
to detect what dependence import the hibernate-jpa-2.0-api and exclude it in your pom
answered Dec 29 '18 at 12:09
sam3131sam3131
63
63
I tried maven clean install. I did not work. Then I removed the dependency which imports hibernate-jpa-2.0-api from pom. But now I'm getting this error. Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]
– Isuru
Jan 1 at 7:01
add a comment |
I tried maven clean install. I did not work. Then I removed the dependency which imports hibernate-jpa-2.0-api from pom. But now I'm getting this error. Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]
– Isuru
Jan 1 at 7:01
I tried maven clean install. I did not work. Then I removed the dependency which imports hibernate-jpa-2.0-api from pom. But now I'm getting this error. Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]
– Isuru
Jan 1 at 7:01
I tried maven clean install. I did not work. Then I removed the dependency which imports hibernate-jpa-2.0-api from pom. But now I'm getting this error. Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]
– Isuru
Jan 1 at 7:01
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53969204%2fhow-to-correct-the-classpath-of-spring-boot-application-so-that-it-contains-a-si%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Check properties and dependency files from github.com/dineshbhagat/spring-boot-web-jpa as reference
– dkb
Dec 29 '18 at 11:49
Also delete files from:
C:/Users/Asus/.m2/repository/org/hibernate/
folder and retry building project. works in some of the cases.– dkb
Dec 29 '18 at 11:51
Your code looks huge - did you make sure it's a minimal example?
– Nino Filiu
Dec 29 '18 at 11:55