spring - @ContextConfiguration fail to load config file in src/test/resources

后端 未结 7 1967
不知归路
不知归路 2021-02-05 04:13

I\'ve tried to load the spring config file in src/test/resources classpath with the following abstract class:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextCon         


        
7条回答
  •  囚心锁ツ
    2021-02-05 05:03

    To be precise, it's the content of the test output directory (target/test-classes) that is on the class path, not src/test/resources. But resources under src/test/resources are copied to the test output directory by the resources:testResources goal (which is bound by default to the process-test-resources phase).

    Having that said, your code looks fine and resources for the test source code should have been copied either by your IDE or by Maven when running tests and should thus be available on the class path. So there must be something else wrong. I can see that your class is a base class for integration tests. Did you configure anything fancy in your pom? Can you show it?

提交回复
热议问题