如果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. include动作标记和include指令标记学习笔记

    我的jsp学习参考书是耿祥义,张跃平编著的jsp大学使用教程这本书,我也向大家推荐这本书,我觉得这本书适合我的学习方式,知识的讲解透彻易懂. include指令标记                   ...

  2. 基本Java数据类型

    一.整型:java中的基本数据类型byte,占用1个字节,8位   取值范围:0000 0000 ~ 1111 1111 (-128 ~ 127)   为什么不是:0000 0000 ~ 1111 1 ...

  3. CentOS 6.5下源码安装MySQL 5.6

    变量lower_case_file_system说明是否数据目录所在的文件系统对文件名的大小写敏感.ON说明对文件名的大小写不敏感,OFF表示敏感. 在my.cnf中[mysqld]更改lower_c ...

  4. Java静态块学习

    静态块是类里面的构造器,对象有构造器那么类也有构造器,类里面的构造器叫做初始化方法.也就是new一个对象他会经过一个构造器.加载一个类,也有被初始化的一片代码,这个就称之为静态块.一个类里面可以有很多 ...

  5. JavaScript系列:replace()函数(第二个参数为函数)

    语法 stringobject.replace(regexp/substr,replacement) 只讲解这个:参数replacement为函数时,这个参数函数的参数代表的意义,以及运行次数,及过程 ...

  6. PHP+jQuery 列表分页类 ( 支持 url 分页 / ajax 分页 )

    /* ******* 环境:Apache2.2.8 ( 2.2.17 ) + PHP5.2.6 ( 5.3.3 ) + MySQL5.0.51b ( 5.5.8 ) + jQuery-1.8.3.mi ...

  7. pdfkit安装使用

    centos 安装pdfkit1.先安装pdfkit依赖包 wkhtmltopdf 安装方式: # wget http://download.gna.org/wkhtmltopdf/0.12/0.12 ...

  8. 必应(Bing)每日图片获取API

    必应(Bing)每日图片获取API January 11, 2015 API http://lab.dobyi.com/api/bing.php 介绍 Value Description title ...

  9. 20145235 《Java程序设计》实验二

    实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉S.O.L.I.D原则 了解设计模式 实验步骤 单元测试 代码及则是结果: public cla ...

  10. 性能测试工具ab

    Apache附带的一个小工具,专门用于HTTP Server的基准测试(benchmark testing),可以同时模拟多个并发请求.ab不像LR那么强大,但是它足够轻便. 格式:ab [optio ...