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

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

问题描述

我想利用Maven为管理项目中的依赖关系提供的功能。我对Maven的工作原理的简要理解是它会获取所需的JAR,然后使用这些库构建项目。

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.

目前,我有一个简单的POM文件设置为测试:

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>

通常在管理项目的依赖项时,我将项目或JAR添加到项目构建路径,然后可以构建我的项目..

Usually when managing dependencies for a project I would add the project or JAR to the project build path and then be able to build my project..

但是当使用M2Eclipse时,依赖关系不会自动添加到构建路径。有没有什么地方需要配置这个来让Eclipse知道Maven正在管理依赖关系?

But when using M2Eclipse the dependencies do are not automatically added to the build path. Is there somewhere I need to configure this to allow Eclipse to know that Maven is managing the dependencies?

推荐答案

如果右击在您的项目中,应该有一个maven下的选项来启用依赖关系管理。就是这样。

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天全站免登陆