HIbernate 的 ehCache 和 Spring MVC 错误
在 Spring MVC 中设置 ehcache 时,我不断收到此错误。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.googlecode.ehcache.annotations.config.internalEhCacheEvictionTask': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: net.sf.ehcache.CacheManager.getName()Ljava/lang/String;
下面是我的设置,我使用 hibernate 3.2.7.GA
<ehcache:config cache-manager="ehCacheManager">
<ehcache:evict-expired-elements interval="60" />
</ehcache:config>
<beans:bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<beans:property name="configLocation" value="/WEB-INF/spring/ehcache.xml"/>
</beans:bean>
Pom.xml
<dependency>
<groupId>com.googlecode.ehcache-spring-annotations</groupId>
<artifactId>ehcache-spring-annotations</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.3.2</version>
<type>pom</type>
</dependency>
</dependencies>
<repositories>
<repository>
<id>terracotta-releases</id>
<url>http://www.terracotta.org/download/reflector/releases</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
I keep getting this error while setting up ehcache in Spring MVC.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.googlecode.ehcache.annotations.config.internalEhCacheEvictionTask': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: net.sf.ehcache.CacheManager.getName()Ljava/lang/String;
Below is my setup, and I am using hibernate 3.2.7.GA
<ehcache:config cache-manager="ehCacheManager">
<ehcache:evict-expired-elements interval="60" />
</ehcache:config>
<beans:bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<beans:property name="configLocation" value="/WEB-INF/spring/ehcache.xml"/>
</beans:bean>
Pom.xml
<dependency>
<groupId>com.googlecode.ehcache-spring-annotations</groupId>
<artifactId>ehcache-spring-annotations</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.3.2</version>
<type>pom</type>
</dependency>
</dependencies>
<repositories>
<repository>
<id>terracotta-releases</id>
<url>http://www.terracotta.org/download/reflector/releases</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在项目网站上下载的包含依赖项的 ehcache-spring-annotations zip 文件包含 ehcache-core 版本 2.2.0。您正在使用 2.3.2。这些版本之间可能不兼容。
The zip file of ehcache-spring-annotations containing the dependencies, downloaded on the project web site, contains ehcache-core version 2.2.0. You're using 2.3.2. There might be an incompatibility between those versions.
通过使用排除使其工作,所以是的,存在冲突问题。
Got it working by using an exclude, so yes there was a clash issue.