Created
January 3, 2013 15:20
-
-
Save madan712/4444241 to your computer and use it in GitHub Desktop.
Spring - How to inject List/ Map using bean? We have a class Country.java with two instance variables city and president. We will set those values using applicationContext.xml.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javaxp; | |
import org.springframework.context.ApplicationContext; | |
import org.springframework.context.support.ClassPathXmlApplicationContext; | |
public class SpringMain { | |
public static void main(String[] args) { | |
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); | |
Country country = (Country) context.getBean("country"); | |
System.out.println(country.getCity()); | |
System.out.println(country.getPresident()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment