2

When I run the maven install everything works fine. All the classes get compiled and my build is also successful. But when I run maven clean install one of the java test classes could not find the xml that is referenced in @ContextConfiguration.

So what could be the problem?

Krishna
  • 49
  • 1
  • 2
  • 8
  • There's probably some other thing putting the XML file where it's expected. Where are you putting the XML file? Is it in `src/main/resources` or `test/main/resources` where it belongs? – James Kingsbery Aug 20 '14 at 14:36
  • I dont have that file in both of those. I have it in some other package. – Krishna Aug 20 '14 at 15:05

1 Answers1

1

You IDE is "helping" you put resources into the classpath.

When running maven clean the entire target/ directory is removed, so if things exist otherwise, it is because someone else copies into it.

Resources in maven usually goes in src/main/resources or src/test/resources unless otherwise configured. Your xml file is probably in a src/main/java or src/test/java folder, and therefore being copied by the IDE.

If you want to have resources inside your java folders, a helpful answer is this one:

In maven how can I include non-java src files in the same place in the output jar?

Community
  • 1
  • 1
Niels Bech Nielsen
  • 4,777
  • 1
  • 21
  • 44
  • Thank you. It resolved my issue. Included the required xml file through resources include in pom.xml – Krishna Aug 21 '14 at 19:26