2010年5月24日

Spring中加载配置文件的方式

摘要: Spring 中加载XML配置文件的方式,好像有3种, XML是最常见的Spring 应用系统配置源。Spring中的几种容器都支持使用XML装配bean,包括: XMLBeanFactory , ClassPathXMLApplicationContext , FileSystemXMLApplicationContext , XMLWebApplicationContext 一:XMLBean... 阅读全文

posted @ 2010-05-24 10:48 小芹菜 阅读(2240) 评论(0) 推荐(2) 编辑

Spring中加载ApplicationContext.xml文件的方式【转】

摘要: 1.利用ClassPathXmlApplicationContext可以从classpath中读取XML文件(1)ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); UserDao userDao = (UserDao)context.getBean("userDao"... 阅读全文

posted @ 2010-05-24 10:46 小芹菜 阅读(10774) 评论(0) 推荐(2) 编辑

Spring

摘要: 第3章Spring有了spring,我们就不用再写工厂方法,不用发愁怎么把写出来的各个代码装配在一起,不过我们选择Spring的原因也不光是为了IOC,而是考虑到现在JavaEE中很多开源项目都提供了Spring整合使用的方法,可以为我们节省相当多的精力和时间。3.1.在项目中使用Spring3.1.1.直接构造ApplicationContext如果我们可以applicationContext.... 阅读全文

posted @ 2010-05-24 10:45 小芹菜 阅读(2214) 评论(0) 推荐(3) 编辑

spring如何使用多个xml配置文件 【转】

摘要: 1, 在web.xml中定义 contextConfigLocation参数.spring会使用这个参数加载.所有逗号分割的xml.如果没有这个参数,spring默认加载web-inf/applicationContext.xml文件.<context-param><param-name>contextConfigLocation</param-name><... 阅读全文

posted @ 2010-05-24 10:31 小芹菜 阅读(5836) 评论(0) 推荐(2) 编辑

Spring中使用classpath加载配置文件浅析[转]

摘要: 在应用Spring的工程中,使用class path的方式加载配置文件应该是最常用的做法,然而对大部分人来说,刚开始使用Spring时,几乎都碰到过加载配置文件失败的情况,除了配置上的错误外,很多时候是因为配置文件的路径和程序中指定的加载路径不一致,从而导致配置文件找不到,或是加载了错误地方的配置文件。本文将就Spring如何从class path中加载配置文件做一些简要的分析。情形一:使用cla... 阅读全文

posted @ 2010-05-24 10:21 小芹菜 阅读(2465) 评论(1) 推荐(2) 编辑

Application context 和Resource 路径[转]

摘要: 构造application context application context构造器通常使用字符串或字符串数组作为资源(比如组成context定义 的XML文件)的定位路径。当这样的定位路径没有前缀时,指定的 Resource 类型会通过这个路径来被创建并被用来载入bean的定义,这都取决于你所指定的application context。例如,如果你使用下面的代码来创建ClassPathXm... 阅读全文

posted @ 2010-05-24 10:10 小芹菜 阅读(1913) 评论(0) 推荐(2) 编辑

导航