我手上有一个遗留的应用程序,并且有一个非常大的混合属性+ini配置文件。因为它也使用基于xml的spring配置,所以我在考虑做一些改进。尤其是我在考虑使用:
<util:properties id="properties" location="classpath:test.cfg"/>
<context:property-placeholder location="classpath:test.cfg" ignore-resource-not-found="false"/>
这两行代码本来可以替代其他一些基于xml的代码
<bean id="configurations"
class="org.springmodules.commons.configuration.CommonsConfigurationFactoryBean">
<property name="configurations">
<list>
<bean class="org.apache.commons.configuration.SystemConfiguration"/>
<bean class="org.apache.commons.configuration.INIConfiguration">
<constructor-arg type="java.net.URL"
value="classpath:test.cfg"/>
</bean>
</list>
</property>
</bean>
<!-- pass through configuration parameters to spring as palceholders -->
<bean id="configuration" factory-bean="&configurations" factory-method="getConfiguration"/>
<bean id="properties" factory-bean="&configurations" factory-method="getObject"/>
<bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties" ref="properties"></property>
</bean>
不幸的是,这两个注解似乎不适用于基于节的ini配置文件。有没有什么方法可以让我不知道的工作呢?
暂无答案!
目前还没有任何答案,快来回答吧!