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