If you need a list of links to other named beans, you can simply use the standard Groovy list notation, and everything will be resolved correctly:
beans {
listHolder(ListHolder){
items = [item1, item2]
}
}
but this does not work when the "elements" must be anonymous inside the beans, which is equivalent to XML
<bean id="listHolder" class="com.example.ListHolder">
<property name="items">
<list>
<bean class="com.example.Item1" />
<bean class="com.example.Item2" />
</list>
</property>
</bean>
You will need to do something like
beans {
'listHolder-item-1'(Item1)
'listHolder-item-2'(Item2)
listHolder(ListHolder){
items = [ref('listHolder-item-1'), ref('listHolder-item-2')]
}
}
source
share