https://blog.csdn.net/yulsh/article/details/70049525
https://blog.csdn.net/chendeyou5/article/details/79449472
相较于传统的读取property配置文件的方法,为了数据的安全常把数据源配置与工程分类,放在项目的外部。
配置方法:
在spring的applicationContext文件中添加如下代码:
<context:property-placeholder location=“file:C:/conf/config.properties” order=“1” ignore-resource-not-found=“true” ignore-unresolvable=“true” />
<context:property-placeholder location=“classpath*:/config.properties” order=“2” ignore-resource-not-found=“true” ignore-unresolvable=“true” />
1
2
3
order代表加载顺序,当1加载成功 2不会覆盖1中的内容,1加载不成功加载2。
也可以通过bean的方式: