Hibernate 5依赖项在jboss-logging上与自身版本冲突

时间:2018-02-14 03:46:02

标签: hibernate maven

我正在实现一个jsf + spring + hibernate web应用程序,我正在使用hibernate-entitymanager 5.2.13,这是我对pom.xml的依赖:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>5.2.13.Final</version>
</dependency>

但我收到错误AbstractMethodError。我从here得到线索,并使用命令mvn enforcer:enforce找出依赖冲突。这是输出:

Dependency convergence error for org.jboss.logging:jboss-logging:3.3.1.Final paths to dependency are:
+-com.peter:Project:0.0.1-SNAPSHOT
  +-org.hibernate:hibernate-entitymanager:5.2.13.Final
    +-org.jboss.logging:jboss-logging:3.3.1.Final
and
+-com.peter:Project:0.0.1-SNAPSHOT
  +-org.hibernate:hibernate-entitymanager:5.2.13.Final
    +-org.hibernate:hibernate-core:5.2.13.Final
      +-org.jboss.logging:jboss-logging:3.3.1.Final
and
+-com.peter:Project:0.0.1-SNAPSHOT
  +-org.hibernate:hibernate-entitymanager:5.2.13.Final
    +-org.hibernate.common:hibernate-commons-annotations:5.0.1.Final
      +-org.jboss.logging:jboss-logging:3.3.0.Final

显然,hibernate-entitymanager:5.2.13.Finaljboss-logging的多个版本,来自不同包的jboss-logging:3.3.1.Finaljboss-logging:3.3.0.Final。我该如何解决这个问题?可以通过排除hibernate-commons-annotations包下的那个来修复吗?我试着像这样排除它:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>5.2.13.Final</version>
    <exclusions>
        <exclusion>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>

但它出现了另一个错误,说jboss-logging类是必需的,我想这是因为上面的尝试是从依赖项中排除所有jboss-logging。我想要的是仅从org.hibernate.common:hibernate-commons-annotations中排除一个。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

尝试在 pom.xml 中使用dependencyManagement选择版本。

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>3.3.1.Final</version>
        </dependency>
    </dependencies>
</dependencyManagement>