package com.test;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
public class SpringMain {
/**
* @param args
*/
public static void main(String[] args) {
SpringBean bean = null;
XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource( "applicationContext.xml" ));
bean = (SpringBean)factory.getBean( "test1" );
bean.sayHello();
ApplicationContext act = new ClassPathXmlApplicationContext( "applicationContext.xml" );
bean = (SpringBean)act.getBean( "test1" );
bean.sayHello();
factory = new XmlBeanFactory(new FileSystemResource( "F:\\ccc\\workspace_zuhe\\Test\\src\\applicationContext.xml" ));
bean = (SpringBean)factory.getBean( "test1" );
bean.sayHello();
}
}
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
public class SpringMain {
/**
* @param args
*/
public static void main(String[] args) {
SpringBean bean = null;
XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource( "applicationContext.xml" ));
bean = (SpringBean)factory.getBean( "test1" );
bean.sayHello();
ApplicationContext act = new ClassPathXmlApplicationContext( "applicationContext.xml" );
bean = (SpringBean)act.getBean( "test1" );
bean.sayHello();
factory = new XmlBeanFactory(new FileSystemResource( "F:\\ccc\\workspace_zuhe\\Test\\src\\applicationContext.xml" ));
bean = (SpringBean)factory.getBean( "test1" );
bean.sayHello();
}
}