rob*_*mag 25 java junit spring maven-2 junit4
我尝试使用以下抽象类在src/test/resources类路径中加载spring配置文件:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:/applicationContext.xml"})
public class BaseIntegrationTests {
}
Run Code Online (Sandbox Code Playgroud)
我在src/test/resources中有applicationContext.xml文件,但Spring无法加载它.
谢谢.
Pas*_*ent 26
确切地说,它是类路径上的测试输出目录(target/test-classes
)的内容,而不是src/test/resources
.但在资源src/test/resources
被复制到测试输出目录由resources:testResources
目标(这是默认绑定的process-test-resources
阶段).
话虽如此,您的代码看起来很好,测试源代码的资源应该由IDE或Maven在运行测试时复制,因此应该在类路径上可用.所以一定有别的错误.我可以看到你的类是集成测试的基类.你在pom中配置了什么花哨的东西吗?你能表现出来吗?
pra*_*kre 16
尝试使用*,以便它可以搜索您的类路径
@ContextConfiguration(locations={"classpath*:applicationContext.xml"})
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
67032 次 |
最近记录: |