【发布时间】:2012-04-19 17:28:09
【问题描述】:
在我们正在使用的 Spring 配置的一个领域中:
applicationContext.xml:
<bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" lazy-init="true">
<property name="configLocation" value="classpath:ehcache.xml"/>
</bean>
但是,ehcache.xml 不是标准的 spring bean 配置文件,而是包含 ${ehcache.providerURL},我们希望根据我们在其他地方使用 PropertyPlaceHolderConfigurer 配置的内容来替换它:
ehcache.xml:
<cacheManagerPeerProviderFactory
...
providerURL=${ehcache.providerURL}
...
</cacheManagerPeerProviderFactory>
我可以使用 Maven/profile/filter 组合,但这会创建一个特定于其构建环境的构建。我真正想做的是在运行时预处理 ehcache.xml,根据 PropertyPlaceHolderConfigurer 读取的属性执行替换,然后将结果传递给 EhCacheManagerBean。
此时,我正在考虑以某种方式复制@Value 注释背后的功能,因为它可以替换“bla bla bla ${property} bla bla bla”,除非我需要在从磁盘读取文件后执行此操作。
关于如何解决这个问题的任何想法?
谢谢。 -AP_
【问题讨论】: