我正在使用 Spring(3.1) 配置文件通过 util:properties 加载属性文件:
<beans profile="local">
<util:properties id="myProps"
location="classpath:local.properties" />
</beans>
<beans profile="dev">
<util:properties id="myProps"
location="classpath:dev.properties" />
</beans>
我通过运行时参数调用配置文件(在 TC 服务器上运行):-Dspring.profiles.active=local
但我得到了错误There are multiple occurrences of ID value 'myProps'
之前它是与其他 bean 定义一起运行的,但是一旦util:properties
添加后我收到错误。
确保您的 xsd 声明使用 >= 3.1 版本beans
and util
命名空间:
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd ">
最可能的错误原因是忘记将 util 声明设置为 3.1,如果正如您所说,这适用于其他 bean,但不适用于使用 声明的 beanutil
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)