1
有没有使用注释来配置EHcache的方法。带注释的EhCache配置 - 休眠
我有一个启用缓存的Spring/Hibernate项目。目前我正在使用ehcache.xml来定义实体如何被缓存的配置。
这是我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/ehcache"/>
<defaultCache
.
.
.
</defaultCache>
<cache name="exmaple.model.User" maxEntriesLocalHeap="1000" eternal="false"
timeToIdleSeconds="120" timeToLiveSeconds="300">
<persistence strategy="localTempSwap"/>
</cache>
</ehcache>
我在想,如果这是可能做同样与@Entity的顶部,而不是使用此XML文件的注释。
它看起来像控制转换为编程,但似乎事情比使用XML更复杂。话虽如此,我真的很感谢您提供的解决方案,因为它向我展示了如何从Java实现缓存,以备将来需要时使用。 –
我会等待几天,然后再接受这个答案,以防其他人找出使用注释的方法:) –
祝你好运;-) – Henri