我想在src/test/java的測試工具中使用我的src/main/resources目錄中的applicationContext.xml。我如何加載它?我曾嘗試過:maven spring測試應用程序上下文
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:applicationContext.xml")
public class TestService {
...
}
但是得到一個文件找不到錯誤。我正在使用Maven和Spring。謝謝。
'classpath *'搜索類路徑中的所有條目。這將從src/main/resources中包含'applicationContext.xml'的目錄。它還會在classpath上搜索jar。 –
非常好,乾淨的解決方案。 – bretter