开门见山
我的项目是用maven部署的,该文件在资源文件里,你们若不是,可放在src文件里,或需要的目录里。
在xmlns:xsi="xxx"的下一行加入
xmlns:context="http://www.springframework.org/schema/context"
在xsi:schemaLocation="xxx"里面的字符串中加入
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd
注:Spring里有不少命名空间,最好自己仔细观察,找到其中规律,像上面这三行和原文中的比较。
<context:property-placeholder location="classpath:filename.properties"/>
<property name="propertyName" value="${propertiesName}"/>
注意: 如果需要加载所有的properties文件,可以使用*.properties表示加载所有的properties文件
注意: propertyName,指属性名,propertiesName指properties文件中的属性名
原文:https://www.cnblogs.com/shuiguo/p/14613300.html