0
我有一个休眠和MySQL的春天休息应用程序。Ehcache在Spring中找不到名字?
服务的ehcache在tomcat中测试并失败。
春天的Ehcache
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcache" />
</bean>
<bean id="ehcache"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:ehcache/cache.xml" />
<property name="shared" value="true" />
</bean>
语境
<cache:annotation-driven />
<context:component-scan base-package="com.example" />
...
<import resource="classpath:spring/spring-cache.xml" />
Cache.xml
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"
monitoring="autodetect" dynamicConfig="true" maxBytesLocalHeap="150M">
<diskStore path="java.io.tmpdir" />
<cache name="byCategory" eternal="false" diskSpoolBufferSizeMB="20"
timeToIdleSeconds="300" timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU" transactionalMode="off">
</cache>
</ehcache>
休眠缓存只有在PROD
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
</prop>
我有一个门面与一个mtehod具有注释
@Cacheable(值= { “byCategory”},键= “#ids.toString()” )
这个测试运行正常,因为没有使用hibernate ehcache,但在prod中CacheManager不加载我在xml中定义的名称。
可以合并hibernate和owns的名称吗?
Hibernate和Spring基于缓存是不同的东西,因此缓存是不共享的。 –