如何在 Eclipse 中将 GitHub 托管项目作为 Java 项目导入? [英] How to import a GitHub hosted project as a Java Project in Eclipse?

查看:39
本文介绍了如何在 Eclipse 中将 GitHub 托管项目作为 Java 项目导入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的 GitHub 上分叉了这个项目:

  • 导入向导提供了以下 3 个选项:

    如果我选择第一个,它会显示未找到项目",如果我选择第二个,我不知道如何继续.

    这是错误的方式吗?我正在使用带有 EGit 插件的 Eclipse Mars (4.5.1).

    解决方案

    您尝试导入的实际上是一个 Maven 项目.首先,确保你已经安装了

  • 只选择master 分支

  • Eclipse 下载完所有内容后,我使用导入工具,而是让 Eclipse 完成并且什么都不做.

此时,有两种可能的方法.存储库已签出到您的机器中,并且需要将项目作为 Maven 项目导入到 Eclipse 中.

方案一:从Git角度导入为Maven项目

注意:此解决方案需要安装 m2e-egit 连接器.

解决方案 2:从导入工具导入为 Maven 项目

  • 转到文件 > 导入... > 现有 Maven 项目".

在这两种情况下,您都会看到以下对话框,您可以在其中选择刚刚下载的所有 Maven 项目并导入它们.

I have forked this project on my GitHub:

and now I'm trying to import (clone) my own origin repo locally. I managed to do it via Bash command line, but I'm not being able to import the project in Eclipse and make it a "Java Project". It's imported as a "Generic project" where packages are seen as plain directories:

The import wizard gives these 3 options:

If I go with the first one it says "No projects found" and if I go with the second I have no idea how to proceed.

Is this the wrong way to go? I'm using Eclipse Mars (4.5.1) with EGit plugin.

解决方案

What you are trying to import is actually a Maven project. First of all, make sure you have M2Eclipse installed, so that the projects can be imported and built automatically.

What I usually do in those cases is the following (pictures are taken with Eclipse Mars 4.5.1, you will need to adjust with your Eclipse installation but it shouldn't change much):

  • Clone the Git repository with the URL: https://github.com/iluwatar/java-design-patterns.git.

  • Select the master branch only

  • Once Eclipse has downloaded everything, I do not use the import facility but instead let Eclipse finish and do nothing.

At this point, there are 2 approaches possible. The repository is checked out into your machine, and the projects need to be imported in Eclipse as Maven projects.

Solution 1: Import as Maven project from the Git perspective

NOTE: this solution requires the m2e-egit connector to be installed. Refer to this answer to locate and install it. The connector will be located at the bottom of the list, below the "m2e Team providers" section, and is named m2e-egit.

  • Still in the Git perspective, expand the Git repository, right-click "Working Tree", and select "Import Maven Projects..."

Solution 2: Import as Maven project from the Import facility

  • Go to "File > Import... > Existing Maven Projects".

In both of those cases, you will be greeted with the following dialog, where you can select all the Maven projects you just downloaded and import them.

这篇关于如何在 Eclipse 中将 GitHub 托管项目作为 Java 项目导入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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