Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring引导Spring数据JPA JBoss EAP 6.4_Jpa_Jboss_Spring Data Jpa - Fatal编程技术网

Spring引导Spring数据JPA JBoss EAP 6.4

Spring引导Spring数据JPA JBoss EAP 6.4,jpa,jboss,spring-data-jpa,Jpa,Jboss,Spring Data Jpa,16:57:41389错误[org.springframework.boot.SpringApplication] (ServerService线程池--86)应用程序启动失败: org.springframework.beans.factory.BeanCreationException:错误 创建在类路径中定义了名为“entityManagerFactory”的bean 资源 [org/springframework/boot/autoconfigure/orm/jpa/hibernatej

16:57:41389错误[org.springframework.boot.SpringApplication] (ServerService线程池--86)应用程序启动失败: org.springframework.beans.factory.BeanCreationException:错误 创建在类路径中定义了名为“entityManagerFactory”的bean 资源 [org/springframework/boot/autoconfigure/orm/jpa/hibernatejpaaautoconfiguration.class]: 调用init方法失败;嵌套异常是 java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/foreignKey

我正在JBoss EAP 6.4中部署一个.war文件

我使用的是Spring启动版本“1.2.4.RELEASE”

我试过:

  • 使用以下内容创建jboss-deployment-structure.xml:

    <jboss-deployment-structure>
        <deployment>
            <exclude-subsystems>
                <subsystem name="jpa" />
            </exclude-subsystems>
            <exclusions>
                <module name="javax.persistence.api" />
                <module name="org.hibernate"/>
            </exclusions>
        </deployment>
    </jboss-deployment-structure>
    
  • 还更改了
    /middleware/jboss64/modules/system/layers/base/javaee/api/main/module.xml

    <module name="javax.persistence.api" export="false"/>
    
  • 但是war文件是使用Gradle2.4生成的,包含
    Hibernate-core-4.3.8.jar
    Hibernate-jpa-2.1-1.0.0.jar
    ,为什么

    我唯一的理论是JBoss正在插入自己的Jpa jar,而不是hibernate jar,这会导致hibernate和Jpa API不匹配,从而导致异常

  • 我认为在spring boot项目中降级Hibernate版本将修复此不匹配,所以我更改了build.gradle

    configurations.all {
        resolutionStrategy {
            eachDependency {
                if (it.requested.group == 'org.hibernate') {  
                    it.useVersion '4.2.19.Final'
                }
            }
        }
    
  • 我犯了以下错误

    无法解析配置的所有依赖项 “:callcentre2:compile”。无法解决 org.hibernate:hibernate验证程序:4.2.19.Final

    (..这里有一些https url,但我不能在这里写,因为它溢出了 不让我保存问题)

    我是否在正确的轨道上降级Hibernate版本?如果是,我如何修复上述构建错误?Hibernate的回购协议是什么

    更新:

    我修正了上面的问题,包括

    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            // Use Hibernate 4.2
            if (details.requested.name == "hibernate-core") {
                details.useTarget "org.hibernate:hibernate-core:4.2.19.Final"
            }
            if (details.requested.name == "hibernate-entitymanager") {
                details.useTarget "org.hibernate:hibernate-entitymanager:4.2.19.Final"
            }
            // Use JPA 2.0
            if (details.requested.name == "hibernate-jpa-2.1-api") {
                details.useTarget "org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final"
            }
        }
    }
    
    但现在我开始使用JBoss EAP 6.4:

    原因:java.lang.LinkageError:链接失败 org/springframework/boot/orm/jpa/hibernate/SpringJtaPlatform(模块 服务模块加载器中的“deployment.callcentre2.war:main” 位于org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:487) [jboss modules.jar:1.3.6.Final-redhat-1] ... 31更多原因:java.lang.NoClassDefFoundError:org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform 位于java.lang.ClassLoader.defineClass1(本机方法)[rt.jar:1.8.0\u 40] 位于java.lang.ClassLoader.defineClass(ClassLoader.java:760)[rt.jar:1.8.0\u 40] 位于org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:361) [jboss modules.jar:1.3.6.Final-redhat-1] 位于org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:482) [jboss modules.jar:1.3.6.Final-redhat-1] ... 53更多原因:java.lang.ClassNotFoundException:org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform 来自服务模块的[模块“deployment.callcentre2.war:main” 装载机]

    configurations.all {
        resolutionStrategy {
            eachDependency {
                if (it.requested.group == 'org.hibernate') {  
                    it.useVersion '4.2.19.Final'
                }
            }
        }
    
    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            // Use Hibernate 4.2
            if (details.requested.name == "hibernate-core") {
                details.useTarget "org.hibernate:hibernate-core:4.2.19.Final"
            }
            if (details.requested.name == "hibernate-entitymanager") {
                details.useTarget "org.hibernate:hibernate-entitymanager:4.2.19.Final"
            }
            // Use JPA 2.0
            if (details.requested.name == "hibernate-jpa-2.1-api") {
                details.useTarget "org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final"
            }
        }
    }