How to configure Eclipse build path to use Maven dependencies?

James Goodwin picture James Goodwin · Jan 10, 2010 · Viewed 410.6k times · Source

I would like to take advantage of the features that Maven provides for managing dependencies in a project. My brief understanding of how Maven works is that it will aquire the JARs needed and then build the project with these libraries.

Currently I have a simple POM file set up as a test:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.jamesgoodwin.test</groupId>
  <artifactId>com.jamesgoodwin.test</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
  </build>
  <dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.0.0.RELEASE</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

To manage dependencies, I usually add the project or JAR to the build path and then i'll be able to build my project..

But when using M2Eclipse the dependencies are not added automatically to the build path. Is there any configuration to let Eclipse know that the Maven is managing the dependencies?

Answer

Buhb picture Buhb · Jan 10, 2010

If you right-click on your project, there should be an option under "maven" to "enable dependency management". That's it.