applicationContext.xml文件放置位置不同而导致的jUnit测试的时候路径的不同
如果applicationContext.xml文件放置在src下面的的时候使用jUint测试的时候编写的路径应该是这样的:
@Test
public void testFindByPage() {
ApplicationContext ctx =
new ClassPathXmlApplicationContext(”applicationContext.xml“);
AccountDao dao = ctx.getBean(AccountDao.class);
但是如果applicationContext.xml文件放置在WEB-INF下面的时候使用jUnit测试的时候编写的路径就要有区别了
如果不这样写,测试的时候就会提示applicationContext.xml文件找不到
private String conf = "WebRoot/WEB-INF/applicationContext.xml";
@Test
public void savetest(){
ApplicationContext ac = new FileSystemXmlApplicationContext(conf);
AllDao ad = ac.getBean(AllDao.class);
User u =new User();
u.setUsername("admin001");
u.setPassword("123456");
ad.register(u); }
applicationContext.xml文件放置位置不同而导致的jUnit测试的时候路径的不同的更多相关文章
- 转:applicationContext.xml文件放置位置不同而导致的jUnit测试的时候路径的不同
如果applicationContext.xml文件放置在src下面的的时候使用jUint测试的时候编写的路径应该是这样的: @Test public void saveTest() { Applic ...
- Spring配置文件详解 - applicationContext.xml文件路径
spring的配置文件applicationContext.xml的默认地址在WEB-INF下,只要在web.xml中加入代码 org.springframework.web.context.Cont ...
- Spring配置文件详解 – applicationContext.xml文件路径
Spring配置文件详解 – applicationContext.xml文件路径 Java编程 spring的配置文件applicationContext.xml的默 ...
- applicationContext.xml文件如何调用外部properties等配置文件
只需要在applicationContext.xml文件中添加一行: <!-- 导入外部的properties文件 --> <context:property-placeholder ...
- Spring中加载ApplicationContext.xml文件的方式
Spring中加载ApplicationContext.xml文件的方式 原文:http://blog.csdn.net/snowjlz/article/details/8158560 1.利用Cla ...
- Spring MVC框架下在java代码中访问applicationContext.xml文件中配置的文件(可以用于读取配置文件内容)
<bean id="propertyConfigurer" class="com.****.framework.core.SpringPropertiesUtil& ...
- ApplicationContext.xml文件详解
想必用过Spring的程序员们都有这样的感觉,Spring把逻辑层封装的太完美了(个人感觉View层封装的不是很好).以至于有的初学者都不知道Spring配置文件的意思,就拿来用了.所以今天我给大家详 ...
- Spring的applicationContext.xml文件
以下是详解Spring的applicationContext.xml文件代码:<!-- 头文件,主要注意一下编码 --><?xml version="1.0" e ...
- 当你的Spring IOC 容器(即applicationContext.xml文件)忘记配到web.xml 文件中时
当你的Spring IOC 容器忘记配到web.xml 文件中时,启动服务器就会报错. 部分错误如下: Caused by: org.springframework.beans.factory.NoS ...
随机推荐
- 在cmd下输入/g无效
如图: 原来一:斜杠得是\ 二:命令和它之间没空格.这个符号和分号的使用是一样的.
- 每天学点GDB 12
本文介绍在archlinux环境下,如何进行内核使用gdb配合qemu进行调试. 1. 安装qemu 2. 编译linux kernel 选择最新的内核版本,规避gcc编译出错的问题具体步骤如 ...
- Javascript 笔记与总结(1-5)闭包
[例1] <script> function t1(){ var age = 20; function t2(){ alert(age); } return t2; } var tmp = ...
- mysql关于字符串字段数据类型
字符串类型 字符串类型指CHAR.VARCHAR.BINARY.VARBINARY.BLOB.TEXT.ENUM和SET.该节描述了这些类型如何工作以及如何在查询中使用这些类型. 类型 大小 用途 C ...
- 在UI线程之外显示Toast
new Thread(){ public void run() { Looper.prepare(); Toast t = Toast.makeText(mContext, R.string.cras ...
- PHP使用Xdebug进行远程调试
PHP使用Xdebug进行远程调试 翻译 by mylxsw posted on 2014/07/14 under 技术文章 > 编程语言 Xdebug提供了客户端与PHP脚本进行交互的接口,这 ...
- 解决Ecshop因为动态ip问题登录后台自动退出
解决Ecshop因为动态ip问题登录后台自动退出 PHP 铁匠 2年前 (2013-07-21) 1130℃ 0评论 修改lib_base.php文件real_ip()函数,添加以下代码即可解 ...
- unity 环境增强
早上过来解决两个问题: (1)VS2012 配置下 VA_X 插件,现在VS在字体颜色方面已经提高很多,但是在类成员实时显示方面还是不方便,或者我没找到吧 (2)安装unityVs插件,微软把 ...
- fortran中如何提供计算程序运行时间?
如下: Real time_begin , time_end1 , time_end2 Integer i , j call CPU_TIME(time_begin) write(*,*) time_ ...
- setattribute兼容
var spanElement = document.getElementById("mySpan"); spanElement.style.cssText = "fon ...