Hibernate搜索和Spring集成的问题

Hibernate搜索和Spring集成的问题,spring,hibernate,maven,struts2,hibernate-search,Spring,Hibernate,Maven,Struts2,Hibernate Search,我一直在尝试将Spring与Hibernate搜索集成在一起,但不同版本会出现不同的异常。 在pom.xml中,我有以下依赖项 <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.1.8.1</version> </dependency&g

我一直在尝试将Spring与Hibernate搜索集成在一起,但不同版本会出现不同的异常。 在pom.xml中,我有以下依赖项

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>2.1.8.1</version>
</dependency>

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-spring-plugin</artifactId>
    <version>2.1.8.1</version>
</dependency>
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.9</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>
    <version>2.5.6</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>2.5.6</version>
</dependency>
<dependency>
    <groupId>asm</groupId>
    <artifactId>asm-all</artifactId>
    <version>3.3</version>
</dependency>
<dependency>
    <groupId>asm</groupId>
    <artifactId>asm</artifactId>
    <version>3.3</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>3.6.7.Final</version>
</dependency>

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-convention-plugin</artifactId>
    <version>2.1.8.1</version>
</dependency>
<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-tiles-plugin</artifactId>
    <version>2.1.8.1</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.15</version>
</dependency>
<dependency>
    <groupId>joda-time</groupId>
    <artifactId>joda-time</artifactId>
    <version>2.0</version>
</dependency>
<dependency>
    <groupId>commons-configuration</groupId>
    <artifactId>commons-configuration</artifactId>
    <version>1.6</version>
</dependency>

<dependency>
    <groupId>com.jgeppert.struts2.jquery</groupId>
    <artifactId>struts2-jquery-plugin</artifactId>
    <version>3.5.1</version>
</dependency>
<dependency>
    <groupId>com.jgeppert.struts2.jquery</groupId>
    <artifactId>struts2-jquery-grid-plugin</artifactId>
    <version>3.5.1</version>
</dependency>
<dependency>
    <groupId>com.jgeppert.struts2.jquery</groupId>
    <artifactId>struts2-jquery-richtext-plugin</artifactId>
    <version>3.5.1</version>
</dependency>
<dependency>
    <groupId>com.jgeppert.struts2.jquery</groupId>
    <artifactId>struts2-jquery-tree-plugin</artifactId>
    <version>3.5.1</version>
</dependency>
<dependency>
    <groupId>com.jgeppert.struts2.jquery</groupId>
    <artifactId>struts2-jquery-mobile-plugin</artifactId>
    <version>3.5.1</version>
</dependency>
但是每当我把这些行添加到pom文件中时

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-search</artifactId>
    <version>3.1.0.GA</version>
</dependency>

org.hibernate
休眠搜索
3.1.0.GA
并尝试部署我的应用程序,然后它会给我一个异常

ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext:215 - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource ....
....
....
Caused by: java.lang.NoSuchMethodError: org.hibernate.util.SoftLimitMRUCache.<init>(I)V
错误org.springframework.web.context.ContextLoader.initWebApplicationContext:215-上下文初始化失败org.springframework.beans.factory.BeanCreationException:创建在ServletContext资源中定义的名为“sessionFactory”的bean时出错。。。。
....
....
原因:java.lang.NoSuchMethodError:org.hibernate.util.SoftLimitMRUCache.(I)V
强制要求:

  • 将所有支柱2罐从
    2.1.8.1
    更改为
    2.3.16
  • 将struts2 jquery插件从
    3.5.1
    更改为
    3.7.0
    (或者,仅适用于较低版本)
建议:

  • 将Hibernate升级到4.x
  • 将Spring升级到3.x
如果可能,将Hibernate用作JPA2实现,而不是将其用作原始Hibernate(旧方法)。然后您将发现(至少对于持久性而言),特别是如果您使用的是JavaEE6


注意:您还需要根据最新版本升级Apache Commons和其他共享库,只需使用Maven Repository获得正确的版本号。

您的库版本太旧,请更新到最新版本。
ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext:215 - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource ....
....
....
Caused by: java.lang.NoSuchMethodError: org.hibernate.util.SoftLimitMRUCache.<init>(I)V