Reputation: 6689
I have Spring project backed up by maven and I am using m2e plugin. Now, some of my files are in the /src/main/webapp/WEB-INF/
folder. Now, the problem is that when I am running tests some of the .xml files with configuration don't work because paths to the resources are breaking.
Firstly, question. When I do on project Run As -> JUnit test
, dose eclipse backs up by doing mvn test
, or is it maven agnostic this way? If so this would explain why after adding
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>/src/main/webapp/</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
to my pom.xml
when I run the test using Run As -> JUnit test
and printing classpath I am not seeing my added location, but doing mvn test
I can see this location added to classpath.
So, is it possible to make eclipse/maven copy some additional files to target/classes
or target/test-classes
or
just add some folders to the runtime classpath when testing the applcation.
Also, is it possible to do such thing in one place so it does not matter if I am running tests using Eclipse gui or just mvn test
from console.
Upvotes: 0
Views: 1143
Reputation: 4164
Unless this has changed recently, your class path in eclipse is still built from your .classpath file. m2e injects some elements, notably dependencies, but source/resource paths still need an entry.
Adding what you need to your .classpath should solve the issue.
Upvotes: 1