Junit手动/自动加载spring配置文件
分配置文件在classpath下和web-inf下两种情况的加载:
- ApplicationContext context = new FileSystemXmlApplicationContext("WebRoot/WEB-INF/applicationContext.xml");
- new ClassPathXmlApplicationContext("applicationContext.xml");// 从classpath中加载
- new FileSystemXmlApplicationContext("classpath:地址");// 没有classpath表示当前目录
注解加载
- @org.springframework.test.context.ContextConfiguration(locations={"file:WebRoot/WEB-INF/applicationContext.xml"})
- @org.springframework.test.context.ContextConfiguration(locations={"classpath:applicationContext.xml"})
- @RunWith(SpringJUnit4ClassRunner.class)
- @ContextConfiguration({"classpath:/ut/applicationContext.xml"})
- public class ScanDecisionFileTest {
- @Before
- public void setUp() throws Exception {
- }
- @After
- public void tearDown() throws Exception {
- }
- @Test
- public void testRun() {
- //fail("Not yet implemented");
- }
- }
Junit手动/自动加载spring配置文件的更多相关文章
- Junit(手动/自动)加载
ssm中测试service层数据 Junit手动加载配置文件 package com.oukele.bookshop_ssm.service; import org.junit.After; impo ...
- ssh整合思想初步 struts2与Spring的整合 struts2-spring-plugin-2.3.4.1.jar下载地址 自动加载Spring中的XML配置文件 Struts2下载地址
首先需要JAR包 Spring整合Structs2的JAR包 struts2-spring-plugin-2.3.4.1.jar 下载地址 链接: https://pan.baidu.com/s/1o ...
- Spring:在web.xml正确加载spring配置文件的方式
web.xml加载spring配置文件的方式主要依据该配置文件的名称和存放的位置不同来区别,目前主要有两种方式. 1. 如果spring配置文件的名称为applicationContext.xml,并 ...
- 在web.xml正确加载spring配置文件的方式
ssm框架整合时一直报出没有创建实例bean的错误,一直以为是代码原因,反复测试了很久,才找到原因是spring配置文件没有正确导入,下图是我的错误示例 web.xml加载spring配置文件的方式主 ...
- junit测试用例加载spring配置文件
junit加载pom引用项目的xml配置文件,如果定义了<beans profile="dev">,必须在测试用例类上面加上标记 @ActiveProfiles(&qu ...
- spring动态加载(刷新)配置文件 [复制链接]
待验证 在程序开发时,通常会经常修改spring的配置文件,不得不重启tomcat来加载spring配,费时费力.如果能在不重启tomcat的情况下,手动动态加载spring 配置文件,动态重启读取s ...
- Spring Web项目spring配置文件随服务器启动时自动加载
前言:其实配置文件不随服务器启动时加载也是可以的,但是这样操作的话,每次获取相应对象,就会去读取一次配置文件,从而降低程序的效率,而Spring中已经为我们提供了监听器,可监听服务器是否启动,然后在启 ...
- spring的applicationContext.xml如何自动加载
一个web工程自动加载的配置文件只有web.xml,想要加载其他.xml必须在web.xml里面进行配置. 用spring的时候需要一个bean容器来管理所有的bean,所有bean默认是写在appl ...
- Spring加载XML配置文件
原创链接:http://www.cnblogs.com/yanqin/p/5282929.html(允许转载,但请注明原创链接) BeanFactory加载单个文件 当使用beanfactory去获取 ...
随机推荐
- 安装webmin
wget http://nchc.dl.sourceforge.net/project/webadmin/webmin/1.740/webmin-1.740.tar.gz 解压缩文件,命令是:tar ...
- Number Game_状态压缩
Description Christine and Matt are playing an exciting game they just invented: the Number Game. The ...
- GET请求和POST请求简单说明
一.概述 * HTTP/1.1协议共定义了8中请求方法:OPTIONS, HEAD, GET, POST, PUT, DELETE, TRACE, CONNECT. * GET方法和POST是我们使用 ...
- OpenFlow Switch学习笔记(七)——Matching Fields
Matching Fields in_port=port Matches OpenFlow port port dl_vlan=vlan Matches IEEE 802.1q Virtual LAN ...
- Java程序如何生成Jar、exe及安装文件
http://blog.csdn.net/luoweifu/article/details/7628006/ 一.用Eclipse生产Jar文件 首先,看一下我的项目的目录结构: 1,项目名字上面点右 ...
- win7建立无线wifi热点的几个常见的问题
命令行开启WiFi方法: 开启WiFi.bat netsh wlan set hostednetwork mode=allow netsh wlan set hostednetwork ssid=ss ...
- ANTLR3完全参考指南读书笔记[03]
前言 文中第4章内容有点多,有点枯燥,但不坚持一下,之前所做的工作就白做了. 再次确认一下总体目标: protege4编辑器中Class Definition中语法解析和错误提示: Java虚拟机规范 ...
- ZOJ 1061 Web Navigation
原题链接 题目大意:模拟一个浏览器,打开一个网页.后退或者前进,输出网址. 解法:用两个堆栈分别表示后退保存的网页和前进保存的网页.初始化时把当前页面压入后退堆栈的栈顶.要注意几点,一个是每次记得要清 ...
- Spring中MultipartHttpServletRequest实现文件上传 生成缩略图
转贴自:http://my.oschina.net/nyniuch/blog/185266 实现图片上传 用户必须能够上传图片,因此需要文件上传的功能.比较常见的文件上传组件有Commons Fil ...
- POJ 3233 Matrix Power Series 矩阵快速幂
设S[k] = A + A^2 +````+A^k. 设矩阵T = A[1] 0 E E 这里的E为n*n单位方阵,0为n*n方阵 令A[k] = A ^ k 矩阵B[k] = A[k+1] S[k] ...