使用Spring Profile加载util:properties会导致多次出现ID [英] Loading util:properties with Spring Profile causes multiple occurrences of ID

查看:298
本文介绍了使用Spring Profile加载util:properties会导致多次出现ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring(3.1)配置文件从util:properties加载属性文件:

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>

然后我通过运行时参数(在TC Server上运行)调用配置文件:-Dspring.profiles.active=local

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

但是我得到了错误There are multiple occurrences of ID value 'myProps'

这以前与其他bean定义一起运行,但是一旦添加util:properties,我就会收到错误消息.

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

推荐答案

确保您的xsd声明对beansutil命名空间都使用> = 3.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  ">

最可能的错误原因是忘记将util声明设置为3.1,如果您说这适用于其他bean,但不适用于使用util声明的bean.

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.

这篇关于使用Spring Profile加载util:properties会导致多次出现ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆