0

我有两个简单的豆子。在第一个 bean 中,它调用一个 init 方法并返回字符串值。

现在我想从第一个 bean init-method 返回的字符串,注入到我的第二个 bean

helloWorldBean3 属性 newKey。请告诉我如何实施此要求。

  <bean id="helloWorldBean2" init-method="loadKey"
 class="com.java.snippets.enterprise.services.HelloWorld2">
 <property name="key" value="${key.supportiveFile}" />

<bean id="helloWorldBean3"
    class="com.java.snippets.enterprise.services.HelloWorld">
       <property name="newKey" ref="???" />
</bean>
4

1 回答 1

0

尝试像这样使用 Spring EL:

<bean id="helloWorldBean3"
    class="com.java.snippets.enterprise.services.HelloWorld">
       <property name="newKey" value=""#{helloWorldBean2.loadKey()}"" />
</bean>
于 2014-04-20T13:13:59.187 回答