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); } }

问题解决!


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM