Bruno Araujo
Bruno Araujo

Reputation: 137

eclipse buildpath error with maven dependency

In my pom.xml i have the following dependency

<dependency>
   <groupId>org.codehaus.woodstox</groupId>
   <artifactId>wstx-asl</artifactId>
   <version>3.2.8</version>
</dependency>

My eclipse download the jar file as expected and my code compiles just fine. But when i execute my JUnit tests i'm gettin a exception wich is the cenario expected for when the dependency is missing.

If i change the dependency to

<dependency>
   <groupId>org.codehaus.woodstox</groupId>
   <artifactId>wstx-asl</artifactId>
   <version>3.2.8</version>
   <scope>system</scope>
   <systemPath>\path\to\wstx-asl-3.2.8.jar</systemPath>
</dependency>

the issue persists. But when i remove the dependency from the pom.xml and add it to the builpath using the standard eclipse way everything works just fine.

Executing a mvn package the tests are executed just fine. Only when i run them in the eclipse envirionment that the issue occurs.

what am i missing here?

Upvotes: 1

Views: 5412

Answers (1)

alex.p
alex.p

Reputation: 2739

Eclipse has a separate build path. When using maven projects within Eclipse you need to rebuild the build path that Eclipse uses to point to the downloaded Maven artifacts.

You do this by running mvn eclipse:eclipse on your project and then clean and build your project from within eclipse.

This Maven plugin rebuilds your .classpath file within your project, this file stores your build path.

See: http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html

Upvotes: 2

Related Questions