有个需求需要读取服务器本地配置文件,实现代码如下即可:
xmlns:context="http://www.springframework.org/schema/context"
<context:property-placeholder
location="classpath:redisServer.properties,file:/home/.settings/redisServer.properties"
ignore-resource-not-found="true" />
使用file读取本地。配置文件同名即可。spring会默认使用最后加载的配置文件。注意是覆盖配置文件里的key。