我有一个带有静态方法的抽象类,它返回一个具体的子类
或另一个,取决于此静态方法的参数。
我如何在 spring 配置文件中定义一个将使用参数调用此静态方法的 bean?
最佳答案
从 Spring 文档中,您只需将参数视为构造函数参数:
<bean id="exampleBean" class="examples.ExampleBean" factory-method="createInstance">
<constructor-arg ref="anotherExampleBean"/>
<constructor-arg ref="yetAnotherBean"/>
<constructor-arg value="1"/>
</bean>
关于java - Spring 和工厂对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2781573/