如何用程序的方式,从 PropertyPlaceholderConfigurer 获取配置
spring 里面有 PropertyPlaceholderConfigurer,可以在 spring 的 applicationContext.xml 中使用 ${...} 。但有一些其他自己的代码,也希望能够直接从 PropertyPlaceholderConfigurer 获取配置。翻看了一阵 PropertyPlaceholderConfigurer 的源代码,看得比较晕。
不知道是否办法做到? --------------------编程问答-------------------- 一颗小红星呢 --------------------编程问答-------------------- PropertyPlaceholderConfigurer没有接触过,呵呵。
帮顶,祝楼主好运 --------------------编程问答--------------------
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="localOverride" value="true"></property>
<property name="locations">
<list>
<value>classpath:conf/*</value>
</list>
</property>
</bean>
这个?你是想在自己的配置文件中用还是自己的类里?
你可以直建立一个配置信息对象类让spring的注入把配置属性值注入到你的类里的对应属性的。 --------------------编程问答-------------------- 帮顶.
补充:Java , Java EE