类路径之外的 ehcache 配置文件

ehcache configuration file outside of classpath

我需要能够从类路径外部读取一个 ehcache 配置文件 (ehcache.xml) 以便能够根据环境拥有不同的文件(例如能够更改多播地址以进行缓存共享).

在我简单地使用 XML 定义的 bean 之前:

<bean id="ehCache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="configLocation" value="#{ @PreferenceService.getEhcacheFileName() }" /> </bean>

PreferenceService.getEhcacheFileName() 发回属性文件中的路径。

如果属性填充了类路径(类路径:ehcache.xml),应用程序将正常工作。

但是如果我想使用绝对路径 (/home/foo/ehcache.xml) 找不到资源。

是否可以使用绝对路径?如果是,我需要使用哪些属性?

configLocation 可以毫无问题地包含绝对路径。

我只是忘记添加文件:在我的属性文件中的路径前面。

所以我现在的路径是:"file:/foo/foo/ehcache.xml"