問題:
I'm using Spring to define stages in my application.我正在使用 Spring 在我的應用程序中定義階段。 It's configured that the necessary class (here called Configurator
) is injected with the stages.它被配置爲必要的類(這裏稱爲Configurator
)注入了階段。
Now I need the List of Stages in another class, named LoginBean
.現在我需要另一個名爲LoginBean
類中的階段列表。 The Configurator
doesn't offer access to his List of Stages. Configurator
器不提供對他的階段列表的訪問。
I cannot change the class Configurator
.我無法更改Configurator
類。
My Idea:我的點子:
Define a new bean called Stages and inject it to Configurator
and LoginBean
.定義一個名爲 Stages 的新 bean 並將其注入Configurator
和LoginBean
。 My problem with this idea is that I don't know how to transform this property:我這個想法的問題是我不知道如何轉換這個屬性:
<property ...>
<list>
<bean ... >...</bean>
<bean ... >...</bean>
<bean ... >...</bean>
</list>
</property>
into a bean.成豆。
Something like this does not work:像這樣的東西不起作用:
<bean id="stages" class="java.util.ArrayList">
Can anybody help me with this?有人可以幫我解決這個問題嗎?
解決方案:
參考一: https://en.stackoom.com/question/A8We參考二: https://stackoom.com/question/A8We