spring读取properties的方法
程序员文章站
2022-06-09 13:30:42
...
首先在配置文件中配置PropertyPlaceholderConfigurer
单个配置文件:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath:jdbc.properties"/>
</bean>
多个配置文件:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
<value>classpath:config.properties</value>
</list>
</property>
</bean>
然后在需要的地方直接以下方式引用:
<property name="url" value="${jdbc.url}"/>
单个配置文件:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="classpath:jdbc.properties"/>
</bean>
多个配置文件:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
<value>classpath:config.properties</value>
</list>
</property>
</bean>
然后在需要的地方直接以下方式引用:
<property name="url" value="${jdbc.url}"/>
上一篇: 什么是回调函数?为什么要使用回调函数?如何使用回调函数?
下一篇: Quartz之Cron表达式