title: How to correct the classpath of spring boot application so that it contains a single, compatible version of javax.persistence.PersistenceContext?
body: <p>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?</p>
  
  <p>//Participant class</p>
  
  <pre><code>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;
      }
  
  }
  </code></pre>
  
  <p>//ParticipantController class</p>
  
  <pre><code>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&lt;Participant&gt; 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);
      }
  
  }
  </code></pre>
  
  <p>//ParticipantService class</p>
  
  <pre><code>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&lt;Participant&gt; participantList = Arrays.asList(
          new Participant("yasas", 23, "Student"),
          new Participant("anu", 28, "accountant"),
          new Participant("banu", 26, "teacher")
      );
  
      @Autowired
      private ParticipantRepository participantRepositoty;
  
  
      public List&lt;Participant&gt; getParticipants(){
  
          return participantList;
      }
  
      public void addParticipant(Participant participant) {
          participantList.add(participant);
  
      }
  
      public void updateParticipant(Participant participant, String name ){
          for (int i=0; i &lt; 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 &lt; 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 &lt; participantList.size(); i++){
              Participant p = participantList.get(i);
              if (p.getName().equals(name)){
                  return p;
              }
          }
          return  null;
      }
  }
  </code></pre>
  
  <p>//POM.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.1.1.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
          &lt;groupId&gt;com.example&lt;/groupId&gt;
          &lt;artifactId&gt;spring2&lt;/artifactId&gt;
          &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
          &lt;name&gt;spring2&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.derby&lt;/groupId&gt;
              &lt;artifactId&gt;derby&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
              &lt;version&gt;2.3.0&lt;/version&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>I expected the server to be started when the application is run. But it gives following error.</p>
  
  <pre><code>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
  </code></pre>