如果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测试的时候路径的不同的更多相关文章

  1. 转:applicationContext.xml文件放置位置不同而导致的jUnit测试的时候路径的不同

    如果applicationContext.xml文件放置在src下面的的时候使用jUint测试的时候编写的路径应该是这样的: @Test public void saveTest() { Applic ...

  2. Spring配置文件详解 - applicationContext.xml文件路径

    spring的配置文件applicationContext.xml的默认地址在WEB-INF下,只要在web.xml中加入代码 org.springframework.web.context.Cont ...

  3. Spring配置文件详解 – applicationContext.xml文件路径

    Spring配置文件详解 – applicationContext.xml文件路径 Java编程                 spring的配置文件applicationContext.xml的默 ...

  4. applicationContext.xml文件如何调用外部properties等配置文件

    只需要在applicationContext.xml文件中添加一行: <!-- 导入外部的properties文件 --> <context:property-placeholder ...

  5. Spring中加载ApplicationContext.xml文件的方式

    Spring中加载ApplicationContext.xml文件的方式 原文:http://blog.csdn.net/snowjlz/article/details/8158560 1.利用Cla ...

  6. Spring MVC框架下在java代码中访问applicationContext.xml文件中配置的文件(可以用于读取配置文件内容)

    <bean id="propertyConfigurer" class="com.****.framework.core.SpringPropertiesUtil& ...

  7. ApplicationContext.xml文件详解

    想必用过Spring的程序员们都有这样的感觉,Spring把逻辑层封装的太完美了(个人感觉View层封装的不是很好).以至于有的初学者都不知道Spring配置文件的意思,就拿来用了.所以今天我给大家详 ...

  8. Spring的applicationContext.xml文件

    以下是详解Spring的applicationContext.xml文件代码:<!-- 头文件,主要注意一下编码 --><?xml version="1.0" e ...

  9. 当你的Spring IOC 容器(即applicationContext.xml文件)忘记配到web.xml 文件中时

    当你的Spring IOC 容器忘记配到web.xml 文件中时,启动服务器就会报错. 部分错误如下: Caused by: org.springframework.beans.factory.NoS ...

随机推荐

  1. 紧挨导航栏下的链接a标签失效

    在我编完网页测试的的时候,发现导航下的链接不能用,不出现小手的图表,而下面的相同的链接都能用.如下图所示 遇到的相同问题的另一个未完成的页面如图 先不谈论其原因,说一下我对第一个页面的解决办法,我在导 ...

  2. 连接sql server的语句

    using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...

  3. Scrum会议1

    小组名称:天天向上 项目名称:连连看 参会成员:王森(Master)张金生 张政 栾骄阳 时间:2016.10.16 会议内容: 1.连连看游戏选取图片素材. 2.连连看的界面设计 3.连连看具体的功 ...

  4. Go学习记录

    操作系统:Windows 一.下载 go官网:https://golang.org/go下载地址:https://golang.org/dl/ 二.安装 安装包有msi安装版本,以及zip压缩包版本. ...

  5. vi 编辑器常用命令

    VI编辑器可以分为3种状态,它们分别是命令模式.输入模式以及末行模式,VI运行后默认进入命令模式. 命令模式:控制屏幕光标的移动,字符.单词或行的删除.替换,复制粘贴数据以及由此进入插入模式和末行模式 ...

  6. CentOS 6 RPM安裝python 2.7

    先说第一种方法,通过rpmbuild编译XXX.src.rpm包([1].[2]): 安装依赖:sudo yum install -y make autoconf bzip2-devel db4-de ...

  7. physical addressing virtual addressing 物理寻址 虚拟寻址

    Computer Systems A Programmer's Perspective Second Edition The main memory of a computer system is o ...

  8. Off-heap Memory in Apache Flink and the curious JIT compiler

    https://flink.apache.org/news/2015/09/16/off-heap-memory.html   Running data-intensive code in the J ...

  9. Map的数据结构

    一:Map<String,Map<String,Map<String,List<A>>>>

  10. 【转】javascript 中that的含义示例介绍

    var that = this;,这代表什么意思呢?this代表的是当前对象,var that=this就是将当前的this对象复制一份到that变量中,下面为大家介绍这样做有什么意义 你可能会发现别 ...