• Caused by: java.io.FileNotFoundException: class path resource [../../resources/config/spring.xml] cannot be opened because it does not exist


    在尝试使用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);
        }
    }

    问题解决!

  • 相关阅读:
    2016.7.31整机升级计划
    UVa 1588
    UVa1587
    Jzoj4714 公约数
    Jzoj4714 公约数
    Jzoj4713 A
    Jzoj4713 A
    Jzoj4711 Binary
    Jzoj4711 Binary
    Jzoj4710 Value
  • 原文地址:https://www.cnblogs.com/zjulanjian/p/11088813.html
Copyright © 2020-2023  润新知