在尝试使用Spring的Test的时候遇到了这个错误

原来的代码:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"../../../resources/config/spring.xml"})
public class TestFund { @Autowired
private FundService fundService; @Test
public void testFundSelectAll() {
//System.out.println("所有基金: " + fundService.selectAll());
System.out.println(fundService);
}
}

原因分析:

  修改spring的配置文件spring.xml的位置

解决方法:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:config/spring.xml")
public class TestFund { @Autowired
private FundService fundService; @Test
public void testFundSelectAll() {
//System.out.println("所有基金: " + fundService.selectAll());
System.out.println(fundService);
}
}

问题解决!

Caused by: java.io.FileNotFoundException: class path resource [../../resources/config/spring.xml] cannot be opened because it does not exist的更多相关文章

  1. 解决CXF的java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml] cannot be opened because it does not exist

    以下是错误信息 九月 25, 2017 8:22:04 下午 org.springframework.web.context.support.XmlWebApplicationContext prep ...

  2. java.io.FileNotFoundException: class path resource [META-INF/xfire/services.xml] cannot be opened because it does not exist

    解决办法: maven创建项目时: META-INF目录下面新建一个xfire文件夹,把services.xml文件放到这个文件夹里,再将整个META-INF拷贝到WEB-INF中 clean一下工程 ...

  3. cxf(3.1.1) 异常Caused by: java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml]

    Caused by: java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml] ...

  4. Caused by: java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be ope

    1.错误描述 java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.tes ...

  5. Caused by: java.io.FileNotFoundException: class path resource [spring/springmvc.xml] cannot be opene

                        Caused by: java.io.FileNotFoundException: class path resource [spring/springmvc. ...

  6. Caused by: java.io.FileNotFoundException: class path resource

    异常: java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.c ...

  7. Caused by: java.io.FileNotFoundException: class path resource [com/cxy/springboot/mapping/] cannot be resolved to URL because it does not exist

    java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.conte ...

  8. spring junit class path resource [ /com/config/spring-core.xml] cannot be opened because it does not exist

    正确写法应该如下: @RunWith(SpringJUnit4ClassRunner.class) //@ContextConfiguration(locations="classpath: ...

  9. 启动tomcat报错Caused by: java.io.FileNotFoundException: class path resource [io/renren/controller/NodeDataController] cannot be opened because it does not exist

    ?? 清理项目,再重启服务就好了.........

随机推荐

  1. 读书笔记 - js高级程序设计 - 第七章 函数表达式

      闭包 有权访问另一个函数作用域中的变量的函数 匿名函数 函数没有名字 少用闭包 由于闭包会携带包含它的函数的作用域,因此会比其它函数占用更多的内存.过度使用闭包可能会导致内存占用过多,我们建议读者 ...

  2. vue element-ui Table数据解除自动响应方法

    在对列表Table进行数据编辑时,会存在table的增删改操作后,列表view也自动响应发生了变化,原因是赋值的数据是一个引用类型共享一个内存区域的.所以我们就不能直接连等复制,需要重新克隆一份新的数 ...

  3. java 实现每次从list中取5000条数据放入新list

    从list中取固定条数的数据放入新的list里 public static <T> List<List<T>> split(List<T> resLis ...

  4. 神经网络 参数计算--直接解析CKPT文件读取

    1.tensorflow的模型文件ckpt参数获取 import tensoflow as tf from tensorflow.python import pywrap_tensorflow mod ...

  5. android studio 3.2 查看Deveice Monitor

    View菜单下面的 Tool Windows 下面的 Devecie File Explorer

  6. JIT Debug Info 简介

    原总结debug调试dump转储文件JITprocdumpJIT Debugging 前言 在上一篇介绍 JIT Debugging 的文章 -- 你需要了解的JIT Debugging 中,我们了解 ...

  7. Win 10 Ctrl + Space 冲突

    1. 说明 在IDE里面Ctrl + space 会与 Windows 输入法相互冲突,并且用Ctrl + Space 切换中英文也很不常用(常用直接shift切换). 2. 操作 控制面板——时钟. ...

  8. Java web之jsp,xml(2020.1.7)

    1.xml文档规则 xml声明 字符集 xml元素的基本规则: 合法标签名 嵌套子元素 空元素

  9. 【模式分解】无损连接&保持函数依赖

    首先引入定义 无损分解指的是对关系模式分解时,原关系模型下任一合法的关系值在分解之后应能通过自然联接运算恢复起来.反之,则称为有损分解. 保持函数依赖的分解指的是对关系分解时,原关系的闭包与分解后关系 ...

  10. pytorch(ch5

    读取图片数据集::# -*- coding: utf-8 -*-import torch as tfrom torch.utils import dataimport osfrom PIL impor ...