Spring引导Spring数据JPA JBoss EAP 6.4
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” 我试过: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
<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"/>
Hibernate-core-4.3.8.jar
和Hibernate-jpa-2.1-1.0.0.jar
,为什么
我唯一的理论是JBoss正在插入自己的Jpa jar,而不是hibernate jar,这会导致hibernate和Jpa API不匹配,从而导致异常
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"
}
}
}
但现在我开始使用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"
}
}
}