如何使用apache commons中的DatabaseConfiguration和属性文件配置数据源名称

时间:2015-12-12 00:12:18

标签: java spring apache-commons apache-commons-config

我正在使用apache commons DatabaseConfiguration将配置属性从属性文件移动到数据库。工作良好。但是,它显然需要数据库定义,我想用jndi数据源名称加载它本身就是一个属性。所以我想保留一个带有该属性的属性文件和一个或两个其他属性,它们将首先加载并被数据库配置使用。

我已经尝试了大约一百万个排列,我似乎无法让它发挥作用。如果我在spring配置中对jndi名称进行硬编码,它可以工作,但无论我是在同一属性配置器中还是单独包含它们,我是否使用order属性......似乎没有任何工作。

这是我无法完成的迭代之一:

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="/WEB-INF/esp.properties" />
    <property name="order" value="10" />
</bean>
<bean id="propertyConfigurer2" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="order" value="20" />
    <property name="properties" ref="dbConfigFactory" />
</bean>

dbConfigFactory存在包含databaseconfiguration bean的工厂。有谁知道怎么做?

0 个答案:

没有答案