java—在spring中将ini文件用作属性占位符时,存在哪些可能性

krcsximq  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(227)

我手上有一个遗留的应用程序,并且有一个非常大的混合属性+ini配置文件。因为它也使用基于xml的spring配置,所以我在考虑做一些改进。尤其是我在考虑使用:

  1. <util:properties id="properties" location="classpath:test.cfg"/>
  2. <context:property-placeholder location="classpath:test.cfg" ignore-resource-not-found="false"/>

这两行代码本来可以替代其他一些基于xml的代码

  1. <bean id="configurations"
  2. class="org.springmodules.commons.configuration.CommonsConfigurationFactoryBean">
  3. <property name="configurations">
  4. <list>
  5. <bean class="org.apache.commons.configuration.SystemConfiguration"/>
  6. <bean class="org.apache.commons.configuration.INIConfiguration">
  7. <constructor-arg type="java.net.URL"
  8. value="classpath:test.cfg"/>
  9. </bean>
  10. </list>
  11. </property>
  12. </bean>
  13. <!-- pass through configuration parameters to spring as palceholders -->
  14. <bean id="configuration" factory-bean="&amp;configurations" factory-method="getConfiguration"/>
  15. <bean id="properties" factory-bean="&amp;configurations" factory-method="getObject"/>
  16. <bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  17. <property name="properties" ref="properties"></property>
  18. </bean>

不幸的是,这两个注解似乎不适用于基于节的ini配置文件。有没有什么方法可以让我不知道的工作呢?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题