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

1k Views Asked by At

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

There are 1 best solutions below

3
On

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.