如何在 Eclipse 中添加 Maven 依赖项? [英] How do I add a Maven dependency in Eclipse?

查看:84
本文介绍了如何在 Eclipse 中添加 Maven 依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我根本不知道如何使用 Maven.我已经用 Eclipse 开发了几年,但还不需要了解它.但是,现在我

  1. 在出现的窗口中,右键单击全局存储库,然后选择进入
  2. 右键单击 "central (http://repo.maven.apache.org/maven2)"并选择重建索引"

  • 请注意,完成下载需要很长时间!!!

  1. 索引完成后,右键单击项目 ->Maven ->添加依赖项并开始输入您要导入的项目的名称(例如hibernate").

  • 搜索结果将自动填写在搜索结果"中.下面的框.

I don't know how to use Maven at all. I've been developing for a couple years with Eclipse and haven't yet needed to know about it. However, now I'm looking at some docs that suggest I do the following:

"To include it within your project, just add this maven dependency to your build."

<repository>
   <id>jboss</id>
   <url>http://repository.jboss.org/maven2</url>
</repository>

   ...
<dependency>
   <groupId>org.jboss.resteasy</groupId>
   <artifactId>resteasy-jackson-provider</artifactId>
   <version>1.1.GA</version>
</dependency>

How do I do this with my Eclipse project?

Please assume I know nothing about Maven. I just figured out it might be installed on my computer by typing mvn on the command line, but that's seriously the extent of my knowledge. I would be happy to continue knowing nothing about Maven if there is an equivalent, non-Maven way of following these instructions with Eclipse.

解决方案

  1. On the top menu bar, open Window -> Show View -> Other
  2. In the Show View window, open Maven -> Maven Repositories

  1. In the window that appears, right-click on Global Repositories and select Go Into
  2. Right-click on "central (http://repo.maven.apache.org/maven2)" and select "Rebuild Index"

  • Note that it will take very long to complete the download!!!

  1. Once indexing is complete, Right-click on the project -> Maven -> Add Dependency and start typing the name of the project you want to import (such as "hibernate").

  • The search results will auto-fill in the "Search Results" box below.

这篇关于如何在 Eclipse 中添加 Maven 依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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