开发者

Spring XML list of beans

I'd like to do something like

<bean id="xxx" class="yyy"开发者_运维知识库>
    <property name="list">
        <list>
            <ref bean="bean1" />
            <ref bean="bean2" />
        </list>
    </property>
</bean>

The beans "bean1" and "bean2" are two different implementations of an interface I. However, they belong to different classes. Does anyone know how I can do this? I have no problem constructing a list of Strings and a list of Integers. Why can't I construct a list of beans?

Thanks,

ktm


The beans "bean1" and "bean2" are two different implementations of an interface I. However, they belong to different classes. Does anyone know how I can do this?

It should work. Try it.

(There should be no runtime type problem here because the runtime type of the list is the raw type of the implementation class used.)

I have no problem constructing a list of Strings and a list of Integers. Why can't I construct a list of beans?

I think you are assuming that it won't work without trying it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜