如何將某個bean作爲值注入另一個bean的屬性?將bean作爲值注入另一個bean的屬性
例如
public class FileNameGenerator
{
private String name;
private String type;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
<bean id="FileNameGenerator" class="FileNameGenerator">
<property name="name">
<value>value1</value>
</property>
<property name="type">
<value>value2</value>
</property>
</bean>
相反,我試圖注入在VALUE1工廠方法豆
<bean id="FileNameGenerator" class="FileNameGenerator">
<property name="name">
<value>
<bean class="SomeOtherClass" factory-method="staticMethodThatReturnsString">
</value>
</property>
<property name="type">
<value>value2</value>
</property>
</bean>
我將如何做到這一點?