spring4.3.3 整合 Hibernate5.2.4 jar包冲突问题 org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V

来源:互联网 发布:unity3d ai寻路 编辑:程序博客网 时间:2024/05/22 17:40

有 IOC 容器 生成 sessionfactory 的时候, 提示 缺少 org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V 方法, 详细的 exception 如下:

警告: Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.orm.hibernate5.LocalSessionFactoryBean#0'
defined in class path resource [spring.xml]:
Invocation of init method failed; nested exception is
java.lang.NoSuchMethodError:
org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V


问题的 分析是 jar 冲突了,

有关 Hibernate 的  jar 我加入比较多, 具体有 :

<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator -->
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-validator</artifactId>
   <version>4.3.2.Final</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator-annotation-processor -->
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-validator-annotation-processor</artifactId>
   <version>4.3.2.Final</version>
  </dependency>


  <!-- https://mvnrepository.com/artifact/net.sf.ehcache/ehcache -->
  <dependency>
   <groupId>net.sf.ehcache</groupId>
   <artifactId>ehcache</artifactId>
   <version>2.10.3</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-ehcache -->
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-ehcache</artifactId>
   <version>5.2.4.Final</version>
  </dependency>


  <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-c3p0 -->
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-c3p0</artifactId>
   <version>5.2.4.Final</version>
  </dependency>

<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
  <dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-core</artifactId>
   <version>5.2.4.Final</version>
  </dependency>


去掉 除 core jar 包外的 Hibernate 相关 jar包即可

因为在 此处 生成 sessionfactroy 的时候 发生 jar 冲突, 具体哪个我再一个一个 测试:


发现, 如果把 core jar包 放在 Hibernate 相关jar包的 首位, jar冲突问题就可以解决


这不科学是吧, pom文件依赖按道理讲 是不跟 位置有关的;


于是 仔细检查, 非常明显的一个 问题,

hibernate-validator-annotation-processor

hibernate-validator

两个jar包 版本跟 core 其他 jar 版本不同


update 两个jar 包 5.2.4后 问题 解决


但新的问题来了


我把 core jar包 放在 首位 就不会报错


这个问题有哪位大牛知道的, 请告诉我一下, 谢谢!




1 0