简体   繁体   English

我该怎么处理pom.xml文件?

[英]What do I do with the pom.xml file?

I have just downloaded a project from github, it has a pom.xml and is missing many dependencies. 我刚从github下载了一个项目,它有一个pom.xml,缺少很多依赖项。

I installed m2e Maven integration in Eclipse plugin but now what do I do? m2e Maven integration in Eclipse plugin安装了m2e Maven integration in Eclipse plugin但现在该怎么办? It's installed and seems to be working but how do I download the dependencies now? 它已安装并且似乎正在运行,但我现在如何下载依赖项?

  • You checkout the git files to a location different from your Eclipse workspace. 您将git文件签出到与Eclipse工作区不同的位置。
  • Start Eclipse on a clean workspace and install m2e. 在干净的工作区上启动Eclipse并安装m2e。 (I usually install m2e-wtp to get web projects) (我通常安装m2e-wtp来获取web项目)
  • Use File -> Import -> Existing Maven projects. 使用文件->导入->现有Maven项目。
  • Point to the pom.xml you want to use in the files checked out above. 指向要在上面检出的文件中使用的pom.xml。
  • Wait while Eclipse downloads half the Internet. 等待Eclipse下载一半的Internet。
  • Ready. 准备。

Right click on your project, run as -> maven install. 右键单击您的项目,运行 - > maven install。

If you can't see these, you either incorrectly installed m2e, or you need to import the project as a maven project. 如果您看不到这些,则要么错误地安装m2e,要么将项目导入为maven项目。

In that case, delete the project from your workspace ( do not check the "delete contents on disk"). 在这种情况下,从工作区中删除项目( 不要检查“删除磁盘上的内容”)。 Right click in the project explorer and click on import... From that dialog, you can select existing maven projects, where you need to navigate to the highest directory containing a pom.xml file. 右键单击项目资源管理器并单击导入...在该对话框中,您可以选择现有的maven项目,您需要导航到包含pom.xml文件的最高目录。

Also, if you have maven installed on your computer (not m2e in eclipse), you can open the directory that contains the pom.xml and just type mvn clean install . 此外,如果您的计算机上安装了maven(而不是eclipse中的m2e),则可以打开包含pom.xml的目录,只需键入mvn clean install This will build your project. 这将构建您的项目。 If you get a "Build success" message, you'll know that the dependencies have been fetched correctly. 如果您收到“构建成功”消息,您将知道已正确获取依赖项。

In eclipse, You have to convert your project to a maven project. 在eclipse中,您必须将项目转换为maven项目。 right click on your project -> maven (or configure) -> convert to maven project (or enable dependencies management). 右键单击您的项目 - > maven(或configure) - >转换为maven项目(或启用依赖项管理)。

This should update your dependencies automatically, if it is not the case then right click your project -> maven -> update project (or update dependencies, it depends on the verion of m2e you are using). 这应该自动更新您的依赖项,如果不是这样,那么右键单击您的项目 - > maven - >更新项目(或更新依赖项,它取决于您正在使用的m2e的版本)。

It should be enough to build the project. 它应该足以构建项目。 The dependencies should be downloaded during the build. 应在构建期间下载依赖项。

Pom.xml files are used for Maven projects. Pom.xml文件用于Maven项目。

Depending on your Eclipse version, maybe it's not compatible with Maven out of the box. 根据您的Eclipse版本,它可能与开箱即用的Maven不兼容。 If not, you can install a Maven plugin (like m2e ) so that the project can be viewed as a Maven project. 如果没有,您可以安装Maven插件(如m2e ),以便可以将项目视为Maven项目。

Maven will do the dependency management (if pom.xml file is configured properly) Maven将进行依赖关系管理(如果pom.xml文件配置正确)

当您右键单击项目 - >运行As-> Maven安装时,它将下载本地存储库中尚未存在的所有依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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