How can you initialize a bean by using a factory method that needs a parameter? I cannot find an example with a method that has parameter, only no params methods... spring docs
Thanks
How can you initialize a bean by using a factory method that needs a parameter? I cannot find an example with a method that has parameter, only no params methods... spring docs
Thanks
Care to scroll down a bit of the docs you gave?
<bean id="exampleBean" class="examples.ExampleBean"
factory-method="createInstance">
<constructor-arg ref="anotherExampleBean"/>
<constructor-arg ref="yetAnotherBean"/>
<constructor-arg value="1"/>
</bean>
Is this what you are looking for :
<bean id="clientService"
class="examples.ClientService"
factory-method="createInstance"/>
public class ClientService {
private static ClientService clientService = new ClientService();
private ClientService() {}
public static ClientService createInstance() {
return clientService;
}
}
Reference 1