0

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が、追加するとエラーが発生します。

4

1 に答える 1

1

beansxsd 宣言がとutil名前空間の両方で >= 3.1 バージョンを使用していることを確認してください。

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 に設定するのを忘れていることですutil

于 2015-10-07T23:11:28.880 に答える