开发者

Define a set outside of a bean in spring ioc

开发者_开发问答I understand that a set can be defined as:

<bean id="toolbox" class="tools.Toolbox">
    <property name="tools">
        <set>
            <ref local="foo" />
            <ref local="bar" />
        </set>
    </property>
</bean>

but I can't find anything in the documentation to allow me to define the set first, for example:

<set id="myTools">
    <ref local="foo" />
    <ref local="bar" />
</set>
<bean id="toolbox" class="tools.Toolbox">
    <property name="tools" ref="myTools"/>
</bean>

Does anyone know if this works or if not how it could be accomplished?


Use <util:set>

Here's the namespace:

xmlns:util="http://www.springframework.org/schema/util"

And the schemaLocation:

http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util-3.0.xsd


You want to use the util namespace

<util:set id="myTools">
    <ref local="foo" />
    <ref local="bar" />
</util:set>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜