【发布时间】:2017-06-19 07:53:43
【问题描述】:
我需要有关 ehCache 配置的帮助。 这些是我所做的:
ehcache.xml 在我的 src/main/resources 文件夹中
<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
公共接口 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")
我收到这样的消息: 找不到在 ServletContext 资源 [/WEB-INF/spring/applicationContext-web.xml] 中定义的名称为“ehcache”的 bean 的类 [org.springframework.cache.ehcache.EhCacheManagerFactoryBean];嵌套异常是 java.lang.ClassNotFoundException: org.springframework.cache.ehcache.EhCacheManagerFactoryBean
【问题讨论】:
-
请添加使用的不同版本的库。
-
我已经解决了将 ehcache.xml 移动到 webapp 文件夹的问题
标签: spring-mvc caching spring-data-jpa ehcache