【Spring】spring配置文件中配置外部配置文件(jdbcConfig.properties等)

问题

如何在Spring的配置文件中配置外部的配置文件,比如jdbcConfig.properties等?

解决

1 <!--读取配置文件-->
2     <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
3         <property name="locations">
4             <list>
5                 <value>classpath:jdbcConfig.properties</value>
6                 <!--要是有多个配置文件,只需在这里继续添加即可 -->
7             </list>
8         </property>
9     </bean>

注意:jdbcConfig.properties放在resources中

使用的话,${}就可以。

原文地址:https://www.cnblogs.com/AirCL/p/14187329.html