首页 > 数据库技术 > 详细

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

时间:2020-12-25 11:43:53      阅读:51      评论:0      收藏:0      [点我收藏+]

问题

如何在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中

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

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!