简体   繁体   English

将Java项目从GitHub导入Eclipse

[英]Import Java project from GitHub to Eclipse

I'm trying to import a project on GitHub into eclipse because there are a few things I want to add to it. 我正在尝试将GitHub上的一个项目导入到eclipse中,因为我想添加一些东西。 However whenever I add it I get a ton of errors and problems with it... 但是每当我添加它时,我都会遇到很多错误和问题......

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. 我已经尝试将它添加到eclipse中并且它不起作用。 I then tried making a project in eclipse and then put the files in, that didn't work. 然后我尝试在eclipse中创建一个项目,然后将文件放入,这不起作用。 I also read online that going to Configure -> Convert to Maven Project would work, and then importing the spigot.jar file that this source depends on. 我还在网上读到, Configure -> Convert to Maven Project将起作用,然后导入此源所依赖的spigot.jar文件。 However that didn't work and just gives me a ton of import errors. 然而,这不起作用,只是给了我很多导入错误。

The errors I am getting: 我得到的错误: 在此输入图像描述

That project is a maven project. 那个项目是一个maven项目。 A simple way is clone that project into your machine, and import it as a maven project, with File - Import - Maven - Existing Maven Project. 一种简单的方法是使用File - Import - Maven - Existing Maven Project将项目导入到您的机器中,并将其作为maven项目导入。

Eclipse will help you resolve the pom file and configure project and download necessary libs. Eclipse将帮助您解析pom文件并配置项目并下载必要的库。

First, make sure you are using Luna, the most recent version. 首先,确保您使用的是最新版本的Luna。

In eclipse, File > Import > Git > Projects from Git > Existing Local Repository. 在eclipse中,文件>导入> Git>来自Git的项目>现有本地存储库。 In the Import Projects from Git screen, click add, then goto the location of the cloned repository. 在“从Git导入项目”屏幕中,单击“添加”,然后转到克隆的存储库的位置。 Click open, finish, then next. 单击打开,完成,然后单击下一步。 Select Java > Java Project, and click next again. 选择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 导入为一般项目

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. 当然,只能在Luna中添加从Git导入选项,所以如有必要,请更新eclipse。

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

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