2

私は次のように配置されたというプロジェクトを持ってXwireup.xmlます:

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

としてインポートModuleします project Xproject Y

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

テストでは、 にある Bean が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

どうすればこれを修正できますか? どうすれば正しいパスを知ることができますか?

4

2 に答える 2

3

それはちょうどあるはずです@ContextConfiguration(locations = {"classpath:com/here/wireup.xml"})

于 2012-07-09T19:57:09.877 に答える
0

リソースのパスはclasspath:com/here/wireup.xml

于 2012-07-09T19:57:37.803 に答える