Java 重复的方法名称&;类文件org/springframework/orm/jpa/vendor/springhibernatejbapersistenceprovider中的签名

Java 重复的方法名称&;类文件org/springframework/orm/jpa/vendor/springhibernatejbapersistenceprovider中的签名,java,hibernate,spring-mvc,spring-data-jpa,Java,Hibernate,Spring Mvc,Spring Data Jpa,我正在使用SpringMVC,并尝试使用SpringDataJPA和Hibernate作为JPA供应商连接MySQL数据库。我在配置JPA配置文件中遇到此错误: group 'com.example' version '1.0-SNAPSHOT' apply plugin: 'war' apply plugin: 'java' sourceCompatibility = 1.8 repositories { mavenCentral() } dependencies {

我正在使用SpringMVC,并尝试使用SpringDataJPA和Hibernate作为JPA供应商连接MySQL数据库。我在配置JPA配置文件中遇到此错误:

group 'com.example'
version '1.0-SNAPSHOT'

apply plugin: 'war'
apply plugin: 'java'

sourceCompatibility = 1.8

repositories {

    mavenCentral()
}

dependencies {
    compile "org.springframework:spring-webmvc:$springVersion"

    compile "org.springframework.security:spring-security-config:$springSecurityVersion"
    compile "org.springframework.security:spring-security-web:$springSecurityVersion"
    compile "org.springframework:spring-context:$springVersion"
    compile "org.springframework:spring-orm:$springVersion"
    compile "org.springframework.data:spring-data-jpa:$springDataJpaVersion"
    compile "org.hibernate:hibernate-core:$hibernateCore"
    compile "javax.inject:javax.inject:1"


    //data validation
    compile "org.hibernate:hibernate-validator:5.4.1.Final"
    compile group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'


    // https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils
    compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.3'

    // https://mvnrepository.com/artifact/mysql/mysql-connector-java
    compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.12'




    // thymleaf dependencies
    compile "org.thymeleaf:thymeleaf-spring5:$thymleafSpring5Version"
    compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4', version: '3.0.2.RELEASE'

    //bootstrap
    compile "org.webjars:bootstrap:$bootstrapVersion"

    providedCompile "javax.el:javax.el-api:$jspElVersion"
    providedCompile "javax.servlet:javax.servlet-api:$javaxServletApi"

    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile "junit:junit-dep:$junitVersion"
    testCompile "org.springframework:spring-test:$springVersion"
    testCompile "org.mockito:mockito-core:$mockitoVersion"
    testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'



    //selenium driver
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.12.0'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version: '3.12.0'


}


task wrapper(type: Wrapper) {
    gradleVersion = '4.1'
}

war {
    baseName = 'collaboration'
}
从Apache日志:

 Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.ClassFormatError: Duplicate method name&signature in class file org/springframework/orm/jpa/vendor/SpringHibernateJpaPersistenceProvider
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582)
    ... 92 more
Caused by: java.lang.ClassFormatError: Duplicate method name&signature in class file org/springframework/orm/jpa/vendor/SpringHibernateJpaPersistenceProvider
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1007)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
    at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2352)
    at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:833)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1278)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1138)
    at org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.<init>(HibernateJpaVendorAdapter.java:80)
    at collaboration.config.SpringDataJpaConfig.jpaVendorAdapter(SpringDataJpaConfig.java:56)
    at collaboration.config.SpringDataJpaConfig$$EnhancerBySpringCGLIB$$39a885b5.CGLIB$jpaVendorAdapter$4(<generated>)
    at 
group 'com.example'
version '1.0-SNAPSHOT'

apply plugin: 'war'
apply plugin: 'java'

sourceCompatibility = 1.8

repositories {

    mavenCentral()
}

dependencies {
    compile "org.springframework:spring-webmvc:$springVersion"

    compile "org.springframework.security:spring-security-config:$springSecurityVersion"
    compile "org.springframework.security:spring-security-web:$springSecurityVersion"
    compile "org.springframework:spring-context:$springVersion"
    compile "org.springframework:spring-orm:$springVersion"
    compile "org.springframework.data:spring-data-jpa:$springDataJpaVersion"
    compile "org.hibernate:hibernate-core:$hibernateCore"
    compile "javax.inject:javax.inject:1"


    //data validation
    compile "org.hibernate:hibernate-validator:5.4.1.Final"
    compile group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'


    // https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils
    compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.3'

    // https://mvnrepository.com/artifact/mysql/mysql-connector-java
    compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.12'




    // thymleaf dependencies
    compile "org.thymeleaf:thymeleaf-spring5:$thymleafSpring5Version"
    compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4', version: '3.0.2.RELEASE'

    //bootstrap
    compile "org.webjars:bootstrap:$bootstrapVersion"

    providedCompile "javax.el:javax.el-api:$jspElVersion"
    providedCompile "javax.servlet:javax.servlet-api:$javaxServletApi"

    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile "junit:junit-dep:$junitVersion"
    testCompile "org.springframework:spring-test:$springVersion"
    testCompile "org.mockito:mockito-core:$mockitoVersion"
    testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'



    //selenium driver
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.12.0'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version: '3.12.0'


}


task wrapper(type: Wrapper) {
    gradleVersion = '4.1'
}

war {
    baseName = 'collaboration'
}
编辑:这是我的build.gradle文件:

group 'com.example'
version '1.0-SNAPSHOT'

apply plugin: 'war'
apply plugin: 'java'

sourceCompatibility = 1.8

repositories {

    mavenCentral()
}

dependencies {
    compile "org.springframework:spring-webmvc:$springVersion"

    compile "org.springframework.security:spring-security-config:$springSecurityVersion"
    compile "org.springframework.security:spring-security-web:$springSecurityVersion"
    compile "org.springframework:spring-context:$springVersion"
    compile "org.springframework:spring-orm:$springVersion"
    compile "org.springframework.data:spring-data-jpa:$springDataJpaVersion"
    compile "org.hibernate:hibernate-core:$hibernateCore"
    compile "javax.inject:javax.inject:1"


    //data validation
    compile "org.hibernate:hibernate-validator:5.4.1.Final"
    compile group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'


    // https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils
    compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.3'

    // https://mvnrepository.com/artifact/mysql/mysql-connector-java
    compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.12'




    // thymleaf dependencies
    compile "org.thymeleaf:thymeleaf-spring5:$thymleafSpring5Version"
    compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4', version: '3.0.2.RELEASE'

    //bootstrap
    compile "org.webjars:bootstrap:$bootstrapVersion"

    providedCompile "javax.el:javax.el-api:$jspElVersion"
    providedCompile "javax.servlet:javax.servlet-api:$javaxServletApi"

    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile "junit:junit-dep:$junitVersion"
    testCompile "org.springframework:spring-test:$springVersion"
    testCompile "org.mockito:mockito-core:$mockitoVersion"
    testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'



    //selenium driver
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.12.0'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version: '3.12.0'


}


task wrapper(type: Wrapper) {
    gradleVersion = '4.1'
}

war {
    baseName = 'collaboration'
}

你知道是什么引起的吗?

请分享你的pom.xml或build.gradle文件。通常不需要为datasoruce和其他应用程序创建bean。只需要在application.properties文件中提供配置@shams.kool在post中添加了build.gradle文件,但据我所知,application.propreties是用于SpringBoot应用程序的,而我使用的是SpringMVC
group 'com.example'
version '1.0-SNAPSHOT'

apply plugin: 'war'
apply plugin: 'java'

sourceCompatibility = 1.8

repositories {

    mavenCentral()
}

dependencies {
    compile "org.springframework:spring-webmvc:$springVersion"

    compile "org.springframework.security:spring-security-config:$springSecurityVersion"
    compile "org.springframework.security:spring-security-web:$springSecurityVersion"
    compile "org.springframework:spring-context:$springVersion"
    compile "org.springframework:spring-orm:$springVersion"
    compile "org.springframework.data:spring-data-jpa:$springDataJpaVersion"
    compile "org.hibernate:hibernate-core:$hibernateCore"
    compile "javax.inject:javax.inject:1"


    //data validation
    compile "org.hibernate:hibernate-validator:5.4.1.Final"
    compile group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'


    // https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils
    compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.3'

    // https://mvnrepository.com/artifact/mysql/mysql-connector-java
    compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.12'




    // thymleaf dependencies
    compile "org.thymeleaf:thymeleaf-spring5:$thymleafSpring5Version"
    compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4', version: '3.0.2.RELEASE'

    //bootstrap
    compile "org.webjars:bootstrap:$bootstrapVersion"

    providedCompile "javax.el:javax.el-api:$jspElVersion"
    providedCompile "javax.servlet:javax.servlet-api:$javaxServletApi"

    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile "junit:junit-dep:$junitVersion"
    testCompile "org.springframework:spring-test:$springVersion"
    testCompile "org.mockito:mockito-core:$mockitoVersion"
    testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'



    //selenium driver
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.12.0'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version: '3.12.0'


}


task wrapper(type: Wrapper) {
    gradleVersion = '4.1'
}

war {
    baseName = 'collaboration'
}