Oct 13th, 2010, 03:41 AM
How to set multiple parameters as setter injection?
I have a use case where I have a setter-method with 2 parameters. Is there a way to let Spring inject two parameters for this setter-method? I have read, that this is possible with constructors, but haven't found anything for setter-methods.
thanks for your help!
Oct 13th, 2010, 06:07 AM
I'm not sure whether it is possible at all. But having a setter method with two parameters contradicts to the JavaBeans specification. And the idea of the spring container is to treat your class exactly as a java bean.
So either break your setter method to two methods or create a composite class that contains the two attributes that you need to pass.
Oct 13th, 2010, 06:16 AM
That's true about the Java bean specification. Therefore I will implement something like a wrapper class, as you mentioned before.
Thanks for the tipp!
Tags for this Thread