首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在Spring bean上下文中声明对象数组

在Spring bean上下文中声明对象数组
EN

Stack Overflow用户
提问于 2010-08-31 23:53:26
回答 4查看 42.5K关注 0票数 20

我试图在Spring上下文文件中创建一个对象数组,这样我就可以将其注入到如下声明的构造函数中:

代码语言:javascript
复制
public RandomGeocodingService(GeocodingService... services) { }

我正在尝试使用<array>标记:

代码语言:javascript
复制
<bean id="googleGeocodingService" class="geocoding.GoogleGeocodingService">
 <constructor-arg ref="proxy" />
 <constructor-arg value="" />
</bean>

<bean id="geocodingService" class="geocoding.RandomGeocodingService">
    <constructor-arg>
        <array value-type="geocoding.GeocodingService">
            <!-- How do I reference the google geocoding service here? -->
        </array>
    </constructor-arg>
</bean>

我在文档中找不到关于如何做到这一点的示例或其他东西。另外,你有任何建议可以更好地实现我正在尝试做的事情,请让我知道:)。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3610804

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档