Spring Book – Chapter 4 – Configuration Styles

Injecting lists

The following listing shows the Bean Configuration in the XML file for injecting lists:

Listing. Injection of list in XML configuration

Injecting Other Collection Types

The topics in this section explain injection of other collection types using XML configuration. Examples are included for collection types such as injecting properties Set and Map.

Injecting properties

Bean Configuration in the XML file for injecting properties is given below:

Listing. Injection of properties in XML configuration

Injecting Set

In the below example, the bean otherBean is local to the main bean beanExample. In the example for injecting list, the bean namely otherBean is global and can be accessed by any other user.

Bean Configuration in the XML file for injecting set is given below:

Listing. Injection of set in XML configuration

Injecting Map

Bean Configuration in the XML file for injecting map is given below:

Listing. Injection of map in XML configuration

Page Visitors: 3549

The following two tabs change content below.
Tomcy John

Tomcy John

Blogger & Author at javacodebook
He is an Enterprise Java Specialist holding a degree in Engineering (B-Tech) with over 10 years of experience in several industries. He's currently working as Principal Architect at Emirates Group IT since 2005. Prior to this he has worked with Oracle Corporation and Ernst & Young. His main specialization is on various web technologies and acts as chief mentor and Architect to facilitate incorporating Spring as Corporate Standard in the organization.
Tomcy John

Latest posts by Tomcy John (see all)

2 thoughts on “Spring Book – Chapter 4 – Configuration Styles

  1. Hi there,

    There is one mistake repeated several times here. The value of the propertyInteger is being set using “ref” instead of “value” and you may want to remove the spaces before and after some of the values/properties to avoid others new to the framework copying and pasting and getting tripped up.

    Apart from that, thanks for making the material available for free.

    1. Sure will do the necessary changes. I wrote the material using MS Word and after that when i copied, these spaces automatically came in.

      Thanks for pointing it out.

      Regards
      Tomcy John

Leave a Reply

Your email address will not be published. Required fields are marked *