开发者社区 问答 正文

spring注解配置ehcache报错:报错

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
	updateCheck="false">
	<diskStore path="java.io.tmpdir" />
	
	<defaultCache maxElementsInMemory="10000" eternal="false"
		overflowToDisk="true" timeToIdleSeconds="300" timeToLiveSeconds="180"
		diskPersistent="false" diskExpiryThreadIntervalSeconds="120" />

	<cache name="DEFAULT_CACHE" maxElementsInMemory="10000" eternal="false"
		timeToIdleSeconds="300000" timeToLiveSeconds="600000" overflowToDisk="true" />
</ehcache>


<ehcache:annotation-driven cache-manager="ehCacheManager" />
	<bean id="ehCacheManager"
		class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
		<property name="configLocation" value="classpath:ehcache.xml" />
	</bean>
@Cacheable(cacheName=CacheConstant.CACHE_NAME)
public List<> findList() {
		
		return;
	}



当访问list方法的时候报错

java.lang.NoSuchMethodError: net.sf.ehcache.Ehcache.getWithLoader(Ljava/lang/Object;Lnet/sf/ehcache/loader/CacheLoader;Ljava/lang/Object;)Lnet/sf/ehcache/Element;

依赖为

<dependency>
			<groupId>com.googlecode.ehcache-spring-annotations</groupId>
			<artifactId>ehcache-spring-annotations</artifactId>
			<version>1.2.0</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context-support</artifactId>
			<version>3.2.1.RELEASE</version>
		</dependency>

谷歌百度都搜了一下,似乎没有人遇到这个错误





展开
收起
kun坤 2020-06-14 08:08:40 456 分享 版权
1 条回答
写回答
取消 提交回答
  • 确定有ehcache的主包没,有的话换最新的试下,还有确认包冲突没(多个ehcache主包)

    ######恩,发了贴后我又自己去捣腾了一下,发现以前是用lib引入的,正打算换成maven的时候就看到了回复,弄完测试一下,果然好了
    2020-06-14 08:08:46
    赞同 展开评论