将 Java 项目从 GitHub 导入 Eclipse

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29245924/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:30:53  来源:igfitidea点击:

Import Java project from GitHub to Eclipse

javaeclipsegithub

提问by user3642449

I'm trying to import a project on GitHub into eclipse because there are a few things I want to add to it. However whenever I add it I get a ton of errors and problems with it...

我正在尝试将 GitHub 上的一个项目导入到 eclipse 中,因为我想向其中添加一些内容。但是,每当我添加它时,我都会遇到大量错误和问题......

The GitHub project is https://github.com/dmulloy2/SwornGuns

GitHub 项目是https://github.com/dmulloy2/SwornGuns

I've tried adding it to eclipse and it didn't work. I then tried making a project in eclipse and then put the files in, that didn't work. I also read online that going to Configure -> Convert to Maven Projectwould work, and then importing the spigot.jarfile that this source depends on. However that didn't work and just gives me a ton of import errors.

我试过将它添加到 eclipse 中,但没有用。然后我尝试在 eclipse 中创建一个项目,然后将文件放入,这不起作用。我还在线阅读了Configure -> Convert to Maven Project会起作用的信息,然后导入spigot.jar该源所依赖的文件。但是,这不起作用,只会给我带来大量导入错误。

The errors I am getting: enter image description here

我得到的错误: 在此处输入图片说明

回答by Mavlarn

That project is a maven project. A simple way is clone that project into your machine, and import it as a maven project, with File - Import - Maven - Existing Maven Project.

该项目是一个 Maven 项目。一个简单的方法是将该项目克隆到您的机器中,并将其作为 maven 项目导入,使用 File - Import - Maven - Existing Maven Project。

Eclipse will help you resolve the pom file and configure project and download necessary libs.

Eclipse 将帮助您解析 pom 文件并配置项目并下载必要的库。

回答by 0az

First, make sure you are using Luna, the most recent version.

首先,确保您使用的是最新版本的 Luna。

In eclipse, File > Import > Git > Projects from Git > Existing Local Repository. In the Import Projects from Git screen, click add, then goto the location of the cloned repository. Click open, finish, then next. Select Java > Java Project, and click next again.

在 Eclipse 中,文件 > 导入 > Git > 来自 Git 的项目 > 现有本地存储库。在从 Git 导入项目屏幕中,单击添加,然后转到克隆存储库的位置。点击打开,完成,然后下一步。选择 Java > Java Project,然后再次单击下一步。

At this point, there are three options.

此时,有三个选项。

  1. Import existing projects
  2. Use the New Project Wizard
  3. Import as General Project
  1. 导入现有项目
  2. 使用新建项目向导
  3. 作为一般项目导入

Pick "Use the New Project Wizard". Then, uncheck "Use Default location", and click browse. Select a folder (You probably want the location you cloned the repo to), click "Open", and give the Project a name. Click next, and make sure that the src/bin folders are setup correctly, and click finish.

选择“使用新建项目向导”。然后,取消选中“使用默认位置”,然后单击浏览。选择一个文件夹(您可能想要将存储库克隆到的位置),单击“打开”,然后为项目命名。单击下一步,确保 src/bin 文件夹设置正确,然后单击完成。

Whew!

哇!

Of course, the Import from Git option was only added in Luna, so update eclipse if necessary.

当然,Import from Git 选项只是在Luna 中添加的,所以需要的话更新一下eclipse。