小编Tri*_*pti的帖子

将ehcache.xml外部化以使用外部属性文件中的属性

我想将属性占位符放在ehcache.xml文件中(如$ {}),以便可以在运行时从外部属性文件(.properties)替换值.就像是:

ehcache.xml(在类路径中):

 <defaultCache
maxElementsInMemory="20000"
eternal="false"
timeToIdleSeconds="${default_TTI}"
timeToLiveSeconds="86400"
overflowToDisk="true"
... />
Run Code Online (Sandbox Code Playgroud)

ehcache.properties(在war/classpath之外):

...
default_TTI=21600
...
Run Code Online (Sandbox Code Playgroud)

目的是能够更改缓存配置,而无需重建应用程序.Spring的PropertyPlaceHolder只适用于我不想要的ehcache的Spring bean definiton(需要将ehcache.xml保存为文件)

这里有类似的帖子,但没有任何东西让我解决.我一直在寻找一个星期!!

我使用Spring 2.5.6,Hibernate 3.2.6和Ehcache 2.4.6

任何帮助或想法是非常Appriciated !!

非常感谢,Tripti.

java spring hibernate ehcache second-level-cache

5
推荐指数
1
解决办法
7650
查看次数

标签 统计

ehcache ×1

hibernate ×1

java ×1

second-level-cache ×1

spring ×1