1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| package com.xiaoguan.test;
import com.xiaoguan.bean.*; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
public class BeanInstatiation { @Test public void testInstatiation5() { ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml"); Student students = applicationContext.getBean("students", Student.class); System.out.println(students); } @Test public void testInstatiation4(){ ApplicationContext applicationContext=new ClassPathXmlApplicationContext("spring.xml"); Person person = applicationContext.getBean("person", Person.class); System.out.println(person); } @Test public void testInstatiation3(){ ApplicationContext applicationContext=new ClassPathXmlApplicationContext("spring.xml"); Gun gun = applicationContext.getBean("gun", Gun.class); System.out.println(gun); } @Test public void testInstatiation2(){ ApplicationContext applicationContext=new ClassPathXmlApplicationContext("spring.xml"); Star st = applicationContext.getBean("sf", Star.class); System.out.println(st); } @Test public void testInstatiation1(){ ApplicationContext applicationContext=new ClassPathXmlApplicationContext("spring.xml"); SpringBean sb = applicationContext.getBean("sb", SpringBean.class); System.out.println(sb); } }
|