2012-07-09 83 views
2

我有一個名爲X項目,該項目具有wireup.xml奠定如下:Spring:如何從jar classpath加載@ContextConfiguration?我得到FileNotFoundException異常

X/ 
Module/ 
     src/ 
      main/ 
       resources/ 
         com.here/ 
           wireup.xml 

我進口的project XModuleproject Y作爲

<dependency> 
     <groupId>com.org.X</groupId> 
     <artifactId>Module</artifactId> 
     <version>master-SNAPSHOT</version> 
    </dependency> 

現在,在測試中,我想豆是在wireup.xml,所以我做了以下操作:

@RunWith(SpringJUnit4ClassRunner.class) 
@ContextConfiguration(locations = {"classpath:com/org/X/Module/src/main/resources/com/here/wireup.xml"}) 
public class MongoSaverTest extends Case { 
    @Autowired 
    private SomeBeanInWireup variable; 
} 

但我得到上運行的測試說

Caused by: java.io.FileNotFoundException: class path resource [com/org/X/Module/src/main/resources/com/here/wireup.xml] cannot be opened because it does not exist 

如何解決這個問題?我如何知道正確的路徑?

回答

3

這應該只是@ContextConfiguration(locations = {"classpath:com/here/wireup.xml"})

0

您的資源的路徑是classpath:com/here/wireup.xml

相關問題