今天在配置多配置文件的時候偶然發現如果我使用
1 <context:property-placeholder location="classpath:filePath.properties"/>
這個進行多行編寫配置文件的時候會出現后面那個文件出現讀取不到的問題
1 <context:property-placeholder location="classpath:jdbc.properties"/> 2 <context:property-placeholder location="classpath:filePath.properties"/>
這樣會導致后面那個配置文件失效
原因:Spring 只會加載第一個context:property-placeholder配置后面的文件將不會再次進行加載,所以導致后面的文件讀取不到
解決辦法:
<context:property-placeholder ignore-unresolvable="true" location="classpath:jdbc.properties,classpath:filePath.properties"/>
加入一個ignore-unresolvable="true"屬性,將文件用,隔開就可以了