package junit.test;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;import cn.itcast.service.PersonService;public class SpringTest { @BeforeClass
public static void setUpBeforeClass() throws Exception {
}
@Test public void instanceSpring(){
ApplicationContext ctx=new ClassPathXmlApplicationContext("beans.xml");
PersonService personService=(PersonService)ctx.getBean("personService");
personService.save();
}
}
 
2012-6-26 10:30:09 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1d1acd3: display name [org.springframework.context.support.ClassPathXmlApplicationContext@1d1acd3]; startup date [Tue Jun 26 10:30:09 CST 2012]; root of context hierarchy
2012-6-26 10:30:09 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [beans.xml]
2012-6-26 10:30:10 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@1d1acd3]: org.springframework.beans.factory.support.DefaultListableBeanFactory@12d15a9
2012-6-26 10:30:10 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@12d15a9: defining beans [personService]; root of factory hierarchy
2012-6-26 10:30:10 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
信息: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@12d15a9: defining beans [personService]; root of factory hierarchy