如何配置 Eclipse 构建路径以使用 Maven 依赖项? [英] How to configure Eclipse build path to use Maven dependencies?

查看:36
本文介绍了如何配置 Eclipse 构建路径以使用 Maven 依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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?

解决方案

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

这篇关于如何配置 Eclipse 构建路径以使用 Maven 依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆