-
Oct 13th, 2010, 03:41 AM
#1
How to set multiple parameters as setter injection?
Hello,
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!
greets,
Oli
-
Oct 13th, 2010, 06:07 AM
#2
Hi Oli,
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.
Cheers,
Ivan
-
Oct 13th, 2010, 06:16 AM
#3
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules