我创建了一个具有休眠依赖项的 Jar 模块
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
并且 Jar 模块可以正确编译。该 Jar 模块由具有休眠依赖关系的 War 模块引用
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.0.Final</version>
</dependency>
在运行时,战争模块给出了一个例外
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource
然后是
java.lang.NoSuchMethodError: org.hibernate.mapping.SimpleValue.<init>(Lorg/hibernate/mapping/Table;)V
似乎hibernate的版本不兼容。一旦从 Jar 模块中删除了依赖项。一切正常。但我需要那个 Jar 模块的依赖。我该如何克服呢?