从Git导入的Eclipse中无法运行项目 [英] Can't run project in Eclipse imported from Git

查看:1092
本文介绍了从Git导入的Eclipse中无法运行项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Github的Eclipse工作区中有一个项目(通过文件 - >导入 - >来自GIT的项目)。
但是,我无法运行示例,因为我在运行方式下的唯一选项是运行配置。



进入运行配置我点击浏览,从GIT导入的项目不在。



任何想法?

解决方案

问题已经在评论中回答了,但我提供了这个答案可能会清除一些误解。



为了将文件夹识别为(Java)项目,Eclipse需要读取(或创建)每个项目的几个文件,如.project和.classpath。如果您没有在项目中使用它们,或者在导入期间不创建它们,则Eclipse将其作为资源导入,或将其导入到一个愚蠢的文件夹中。



如果您的项目由git跟踪,也是一个maven项目,则可以使用Git(命令行或GUI工具)在本地克隆它,然后导入为现有的Maven项目。这将使用您的pom.xml创建上述两个文件,您的项目将可构建。或者,如果您已经按照您的问题中所述导入了它,则可以在Package Explorer上右键单击项目,然后选择配置 - >转换为Maven项目 。这将创建.project,并允许您使用Maven(右键单击 - >运行为..-> Maven构建)和Eclipse的增量构建器(如有必要)构建项目。如果你的maven项目构建一个可执行文件,执行它的选项也将在Run as ..菜单中使用。



如果你有一个更复杂的maven项目一个聚合的pom),并且想要一个运行特定程序的运行配置,您将不得不通过打开运行配置窗口并显式引用java类来自己编写。


I have a project in my Eclipse workspace from Github (via File -> Import -> Projects from GIT). However, I am unable to run the example because the only option I have under "Run As" is "Run Configurations."

After going to "Run Configurations" I click "browse" and the project that I imported from GIT isn't there.

Any ideas?

解决方案

The question is already answered in the comments but I am providing this answer to possibly clear up some misunderstandings.

In order to recognize a folder as a (Java) project, Eclipse needs to read (or create) a few files for each project, like .project and .classpath. If you do not have them in your project, or do no create them during the import, then Eclipse just imports it as a resource, or a dumb folder.

If your project is tracked by git and is also a maven project, you can clone it locally with Git (command line or GUI tool) and then "Import as existing Maven project" in Eclipse. This will use your pom.xml to create the two files mentioned above and your project will be buildable.

Alternatively, if you have already imported it as you described in your question, you can right click on your project on Package Explorer and choose Configure-->Convert to Maven Project. This will create the .project and allow you to build the project using Maven (right click->Run as..-> Maven build) and Eclipse's incremental builder (where necessary). If your maven project builds an executable, the option to execute it will also be available in the Run as.. menu.

If you have a more complex maven project (like an aggregate pom), and want a Run Configuration that runs a specific program, you will have to write it yourself by opening the Run Configurations window and explicitly referencing the java class.

这篇关于从Git导入的Eclipse中无法运行项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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