Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (10.2k points)

'm using Spring to define stages in my application. It's configured that the necessary class (here called Configurator) is injected with the stages.

Now I need the List of Stages in another class, named LoginBean. The Configurator doesn't offer access to his List of Stages.

I cannot change the class Configurator.

My Idea:

Define a new bean called Stages and inject it to Configurator and LoginBean. My problem with this idea is that I don't know how to transform this property:

<property ...>


    <bean ... >...</bean>

    <bean ... >...</bean>

    <bean ... >...</bean>



into a bean.

Something like this does not work:

<bean id="stages" class="java.util.ArrayList">

Can anybody help me with this?

1 Answer

0 votes
by (46k points)

Import the spring util namespace. Then you can define a list bean as follows:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns=""







<util:list id="myList" value-type="java.lang.String">




The value-type is the generics type to be used, and is optional. You can also specify the list implementation class using the attribute list-class.

Browse Categories