ClassPathXmlApplicationContext和FileSystemXmlApplicationContext区别
ClassPathXmlApplicationContext
默认文件路径是src下那一级
classpath:和classpath*:的区别:
classpath: 只能加载一个配置文件,如果配置了多个,则只加载第一个
classpath*: 可以加载多个配置文件,如果有多个配置文件,就用这个
FileSystemXmlApplicationContext
这个类,默认获取的是项目路径,默认文件路径是项目名下一级,与src同级。
如果前边加了file:则说明后边的路径就要写全路径了,就是绝对路径
file:D:/workspace/applicationContext.xml
通过在spring加载的时候直接加载properties文件
<context:property-placeholder location="file:D://property/dinpay.ogg.properties" />
System.out.println(System.getProperty("user.dir"));
Linux和Windows系统识别不一致
如加载配置文件有区别
private static AbstractApplicationContext appContext = null;
private static final String XML_EXPRESSION = "classpath*:applicationContext*.xml"; static {
// 后续来读取命令中的conf 例如 java -Dconf=conf/*.xml -classpath .:lib/*
if (System.getProperty("conf") != null) {
appContext = new FileSystemXmlApplicationContext(System.getProperty("conf").concat("/applicationContext-sync.xml"));
} else {
appContext = new ClassPathXmlApplicationContext(XML_EXPRESSION);
}
}
ClassPathXmlApplicationContext和FileSystemXmlApplicationContext区别的更多相关文章
- spring mvc使用ClassPathXmlApplicationContext或FileSystemXmlApplicationContext和XmlWebApplicationContext类的操作其中 XmlWebApplicationContext是专为Web工程定制的。
一.简单的用ApplicationContext做测试的话,获得Spring中定义的Bean实例(对象).可以用: ApplicationContext ac = new ClassPathXmlAp ...
- Spring ClassPathXmlApplicationContext和FileSystemXmlApplicationContext读取配置文件的方法
先说:ClassPathXmlApplicationContext 这个类,默认获取的是WEB-INF/classes/下的路径,也就是在myeclipse的src下的路径,所以用这个是获取不到WEB ...
- Spring ClassPathXmlApplicationContext和FileSystemXmlApplicationContext
先说:ClassPathXmlApplicationContext 这个类,默认获取的是WEB-INF/classes/下的路径,也就是在myeclipse的src下的路径,所以用这个是获取不到WEB ...
- spring in action-note-2
1.AOP:在软件业,AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术.AOP是OOP的延续,是 ...
- 【spring 区别】ClassXmlAplicationContext和FileSystemXmlApplicationContext的区别
今天写一个简单的spring使用例子,遇到这个问题: 项目结构如下: 代码如下: package com.it.sxd; import java.nio.file.FileSystem; import ...
- Spring中ApplicationContext和beanfactory区别---解析二
一.BeanFactory 和ApplicationContext Bean 工厂(com.springframework.beans.factory.BeanFactory)是Spring 框架最核 ...
- 【Spring学习笔记-2】Myeclipse下第一个Spring程序-通过ClassPathXmlApplicationContext加载配置文件
*.hl_mark_KMSmartTagPinkImg{background-color:#ffaaff;}*.hl_mark_KMSmartTagBlueImg{background-color:# ...
- Spring注解@Resource和@Autowired区别对比、spring扫描的默认bean的Id、程序获取spring容器对象
-------------------------注解扫面的bean的ID问题-------------------------- 0.前提需要明白注解扫描出来的bean的id默认是类名首字母小写,当 ...
- Spring中多配置文件以及寻觅引用其他bean的方式
Spring多配置文件有什么好处? 按照目的.功能去拆分配置文件,可以提高配置文件的可读性与维护性,如将配置事务管理.数据源等少改动的配置与配置bean单独分开. Spring读取配置文件的几种方式: ...
随机推荐
- Leetcode 546.移除盒子
移除盒子 给出一些不同颜色的盒子,盒子的颜色由数字表示,即不同的数字表示不同的颜色.你将经过若干轮操作去去掉盒子,直到所有的盒子都去掉为止.每一轮你可以移除具有相同颜色的连续 k 个盒子(k > ...
- [python][django学习篇][11]后台admin用户登录博客,添加文章---这一章和博客首页设计没有关系
1 如果没有创建超级管理员账号,先要创建python manage.py createsuperuser 2 在admin后台注册模型(如果没有这一步,登录http://127.0.0.1:8000/ ...
- eclipse删除svn下载的文件后如何恢复
Team右键-->与资源库同步-->覆盖/更新
- eslint规范项目代码
安装一系列eslint插件后,填写eslint配置,配置如下 .editorconfig root = true [*] charset = utf-8 indent_style = space in ...
- WF 18 A 想法
UPD:我理解错题意了. 考虑在时刻 $t$ 从站点 $u$ 出发的公交车,将这些车的集合记做 $B(u,t)$,$B(u,t)$ 是个随机变量. 令 $\mathrm{Pr}_{B(u,t)} = ...
- HDU 4557 非诚勿扰(Treap找后继)
非诚勿扰 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Submi ...
- 简单解决 ATL:CString WTL:CString 冲突
//stdafx.h #include <atlbase.h> #include <atlstr.h> #include <atlapp.h> extern CAp ...
- hibernate的各个jar包的作用
hibernate的各个jar包的作用 最基本的Hibernate3.3.2之 JAR包(必要): 包名 位置 用途 hibernate3.jar /hibernate 核心JAR包 antlr.ja ...
- Vijos P1404 遭遇战
背景 你知道吗,SQ Class的人都很喜欢打CS.(不知道CS是什么的人不用参加这次比赛). 描述 今天,他们在打一张叫DUSTII的地图,万恶的恐怖分子要炸掉藏在A区的SQC论坛服务器!我们SQC ...
- c# dynamic,maybe I should say it is just some shortcut for "Object", box and unbox, without the cast
dynamic: void Main() { var b="2"; dynamic a="2"; if(a.GetType()==typeof(int))b+= ...