简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM