我需要有关ehCache配置的帮助。 这些我做了什么:
我的src / main / resources文件夹中的ehcache.xml
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true"
monitoring="autodetect"
dynamicConfig="true">
<diskStore path="java.io.tmpdir" />
<cache name="allNodesCache"
maxEntriesLocalHeap="10000"
maxEntriesLocalDisk="1000"
eternal="false"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="300" timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<persistence strategy="localTempSwap" />
</cache>
我的applicationContext-web.xml
中的ehCache配置<!-- ehCache configuration -->
<cache:annotation-driven />
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cache-manager-ref="ehcache"/>
<!-- EhCache library setup -->
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:config-location="ehcache.xml"/>
的pom.xml:
<!-- ehCache -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.7.2</version>
</dependency>
我的存储库类:
@Repository
public interface NodeRepository扩展了JpaRepository {
@Cacheable(value = "allNodesCache", key = "#node")
@Query("select new com.datum.fnd.domain.Node(c.idNode, c.name, c.address, c.description, c.point) from Node c")
我得到的消息是这样的: 找不到具有名称&#39; ehcache&#39;的bean的类[org.springframework.cache.ehcache.EhCacheManagerFactoryBean]。在ServletContext资源中定义[/WEB-INF/spring/applicationContext-web.xml];嵌套异常是java.lang.ClassNotFoundException:org.springframework.cache.ehcache.EhCacheManagerFactoryBean
答案 0 :(得分:3)
将spring上下文支持依赖项添加到类路径中:
https://mvnrepository.com/artifact/org.springframework/spring-context-support