Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.jpa.repository.config

Tags:

i can't understand ther Error ,what should i do? Correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension.registerBeansForRoot(JpaRepositoryConfigExtension.java:169)

The following method did not exist:

    org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension.registerIfNotAlreadyRegistered(Lorg/springframework/beans/factory/support/AbstractBeanDefinition;Lorg/springframework/beans/factory/support/BeanDefinitionRegistry;Ljava/lang/String;Ljava/lang/Object;)V

The method's class, org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension, is available from the following locations:

    jar:file:/C:/Users/HCL/.m2/repository/org/springframework/data/spring-data-jpa/2.0.2.RELEASE/spring-data-jpa-2.0.2.RELEASE.jar!/org/springframework/data/jpa/repository/config/JpaRepositoryConfigExtension.class

It was loaded from the following location:

    file:/C:/Users/HCL/.m2/repository/org/springframework/data/spring-data-jpa/2.0.2.RELEASE/spring-data-jpa-2.0.2.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension

i added latest versions of dependencies eventhough it will showing again

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 https://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.2.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <version>2.0.2.RELEASE</version>
</dependency>

        <dependency>
    <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>


        <!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api -->
<dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>javax.persistence-api</artifactId>
    <version>2.2</version>
</dependency>
        <!-- https://mvnrepository.com/artifact/javax.transaction/jta -->

        <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>2.3.15.2</version>
</dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Please Help!

like image 973
rayudu Avatar asked Jan 23 '20 17:01

rayudu


1 Answers

You should not mention version for your spring-data-jpa. Spring-boot parent dependency will resolve that automatically.

Instead of this:

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <! -- <version>2.0.2.RELEASE</version>  comment or remove this line -->
</dependency>

Update: You are using spring-boot-starter-parent version 2.2.4 and different spring-data-jpa version, that's why getting error.

like image 173
P3arl Avatar answered Oct 12 '22 06:10

P3arl