国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

初始化spring容器的幾種方法

2019-11-08 20:18:15
字體:
供稿:網(wǎng)友
package ssh.sPRing;import java.io.IOException;import org.springframework.beans.factory.BeanFactory;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;import org.springframework.core.io.Resource;public class Test { @org.junit.Test public void test1(){ ApplicationContext ac=new ClassPathXmlApplicationContext("ssh/spring/applicationContext.xml"); Person p1=(Person)ac.getBean("person"); System.out.println("test1 "+p1); } @org.junit.Test public void test2(){ ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml",this.getClass()); Person p1=(Person)ac.getBean("person"); System.out.println("test2 "+p1); } @org.junit.Test public void test3(){ Resource resource=new ClassPathResource("ssh/spring/applicationContext.xml"); BeanFactory beanFactory=new XmlBeanFactory(resource); Person p1=(Person)beanFactory.getBean("person"); System.out.println("test3 "+p1); } @org.junit.Test public void test4() throws IOException{ Resource resource=new ClassPathResource("applicationContext.xml",this.getClass()); BeanFactory beanFactory=new XmlBeanFactory(resource); Person p1=(Person)beanFactory.getBean("person"); System.out.println("test4 "+p1); } @org.junit.Test public void test5(){ Resource resource=new FileSystemResource("E:/Java/study/WebRoot/WEB-INF/classes/ssh/spring/applicationContext.xml"); BeanFactory beanFactory=new XmlBeanFactory(resource); Person p1=(Person)beanFactory.getBean("person"); System.out.println("test5 "+p1); }}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 沾益县| 宁津县| 隆化县| 乌拉特中旗| 阳春市| 新民市| 攀枝花市| 永福县| 西林县| 贞丰县| 锦州市| 吐鲁番市| 汕头市| 平远县| 通化市| 收藏| 印江| 鹤山市| 张家口市| 荆门市| 阜新市| 红安县| 陆良县| 玉龙| 沧源| 海晏县| 古田县| 开平市| 武强县| 汉川市| 启东市| 贵港市| 登封市| 大邑县| 常德市| 西乌珠穆沁旗| 英吉沙县| 汤原县| 柳州市| 江津市| 施秉县|