您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

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

bubuko 2022/1/25 19:19:07 java 字数 3321 阅读 872 来源 http://www.bubuko.com/infolist-5-1.html

问题 如何在Spring的配置文件中配置外部的配置文件,比如jdbcConfig.properties等? 解决 1 <!--读取配置文件--> 2 <bean id="propertyConfigurer" class="org.springframework.beans.factory.conf ...

问题

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


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶