How to pass a collection as argument to a constructor using Spring based dependency injection
Nikhilesh Reddy Chaduvula
posted 2 years ago
I am using Mongodb
How to pass a collection as constructor argument to the above constructor using spring.
I don't want to use string as argument but i want to pass a collection from spring (Anything is fine but xml is preferred)
My xml goes something like this
You would need to then create a bean with id = myMongoCollection and of class = com.mongodb.DBCollection of course the that bean would have yet another constructor-arg ref of a bean of type com.mongodb.DB and a string. You would continue this pattern until you just had simple types. Something like this is much easier to do with Java Config but you said you prefer XML.