国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 章丘市| 马公市| 宁阳县| 东源县| 淮南市| 唐山市| 曲水县| 孝昌县| 邹平县| 芦山县| 兰坪| 泰兴市| 彭泽县| 宜兰县| 辽宁省| 平舆县| 泗水县| 池州市| 石门县| 嵊泗县| 达拉特旗| 谢通门县| 屯昌县| 乐业县| 青海省| 福安市| 竹北市| 南汇区| 老河口市| 太仆寺旗| 十堰市| 长海县| 滦南县| 内乡县| 九龙坡区| 武城县| 中超| 杨浦区| 湖南省| 宜良县| 麦盖提县|