Test-resources of dependencies not in classpath?

I have a multi module Spring project that I set up using Maven: my-root (pom) - my-logic - my-webapp (depending on my-logic) - my-consoleapp (depending on my-logic) My Test classes inherit from `AbstractTransactionalJUnit4SpringContextTests` and use `@ContextCofiguration` for setting up the `ApplicationContext`. E.g. the test class for a Spring Controller: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:applicationContext-logic-test.xml", "classpath:applicationContext-web-test.xml"}) public class ControllerTest extends AbstractTransactionalJUnit4SpringContextTests { @Autowired private ApplicationContext applicationContext; ... } As you can see there is a config XML per module. I have seperate configs for tesing, residing in test/resources of each module (and additionaly having the suffix "-test"). This all works (the class compiles, runs and the JUnit tests are successful) **if** I run the JUnit test in Eclipse. Now to my problem: **Running the test using Maven will NOT work!** (e.g. with "Run As">"Maven install" on `my-root` (I use m2eclipse)). Specifically, it will throw the following exception: > java.io.FileNotFoundException: class path resource [applicationContext-logic-test.xml] cannot be opened because it does not exist` It seems that Maven does not add the files from `my-logic/src/test/resources` to the classpath that is set up when running the unit tests of `my-webapp`. How can I fix that?

以上就是Test-resources of dependencies not in classpath?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准