简体   繁体   English

ehcache配置文件在类路径之外

[英]ehcache configuration file outside of classpath

I need to be able to read an ehcache configuration file ( ehcache.xml) from outside the classpath to be able to have differents files by environment (to be able for example to change the multicast adress for cache sharing). 我需要能够从类路径之外读取ehcache配置文件(ehcache.xml),以便能够根据环境具有不同的文件(例如,能够更改用于缓存共享的多播地址)。

Before I was simply using an XML defined bean : 在我简单地使用XML定义的bean之前:

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

PreferenceService.getEhcacheFileName() send back a path in a properties file. PreferenceService.getEhcacheFileName()发送回属性文件中的路径。

if the propertie is filled with a classpath path (classpath:ehcache.xml), the application work properly. 如果属性用类路径路径(classpath:ehcache.xml)填充,则应用程序将正常运行。

But if I want to use an absolute path (/home/foo/ehcache.xml) the resource is not found. 但是,如果我要使用绝对路径(/home/foo/ehcache.xml),则找不到资源。

Is it possible to use an absolute path ? 是否可以使用绝对路径? And if yes what properties do I need to use ? 如果是,我需要使用哪些属性?

configLocation can contain an absolute path without any trouble. configLocation可以包含一个绝对路径,没有任何麻烦。

I just forgot to add the file: in front of the path in my properties file. 我只是忘了添加文件:属性文件中路径的前面。

So my path is now : "file:/foo/foo/ehcache.xml" 所以我的路径现在是:“ file:/foo/foo/ehcache.xml”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM