Spring-Spring CoreNo Comments

In this post, I will  show you how to inject values into collections type (List, Set, Map, and Properties).

This is common case we will face in real project, so there are 4 major collection types are supported :

  1. List – <list/>
  2. Set – <set/>
  3. Map – <map/>
  4. Properties – <props/>
  • Spring beans

A normal object, with four collection properties to using for example :

CarService : 

  • Configuration file

spring-core.xml : 

And now, let go to detail each of them :

  • List

  • Set

  • Map

  • Properties

Note :

If you want to pass null or empty value :

And if you want to inject a bean to collection : 


That’s it, just comment here or asking me in Questions tab if you have any question.




Be the first to post a comment.

Add a comment