Loading util:properties with Spring Profile causes multiple occurrences of ID

孤街浪徒 提交于 2019-12-19 04:55:43

问题


I am using Spring(3.1) profiles to load property files vis 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>

And I invoke the profile via a runtime parameter(running on TC Server):-Dspring.profiles.active=local

But I get the error There are multiple occurrences of ID value 'myProps'

This was running previously with other bean definitions but once the util:properties was added I get the error.


回答1:


Make sure your xsd declarations are using >= 3.1 versions for both beans and util namespaces:

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  ">

Most likely cause of error would be forgetting to set util declaration to 3.1, if as you say this works for other beans but not those declared using util.



来源:https://stackoverflow.com/questions/20424699/loading-utilproperties-with-spring-profile-causes-multiple-occurrences-of-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!