简体   繁体   English

在Eclipse中为可运行的Java项目使用远程git资源

[英]Using a remote git resource in eclipse for a runnable java project

My problem currently is that I've got a project on bitbucket, and I've been able to create a local repository of the project through Eclipse. 目前我的问题是我在bitbucket上有一个项目,并且已经能够通过Eclipse创建该项目的本地存储库。

However, when attempting to import the repository into Eclipse to run the project I come up against a couple of issues. 但是,当尝试将存储库导入Eclipse以运行项目时,我遇到了两个问题。

  1. Create a new project from the git repository. 从git仓库创建一个新项目。 This does create a new project and links it to the local repo, but I'm not able to run is as a java project. 这确实创建了一个新项目并将其链接到本地​​存储库,但是我无法作为Java项目运行。 The reason being that all of the options under the 'run configurations' are blank. 原因是“运行配置”下的所有选项均为空白。 And Eclipse doesn't recognise the project as a project at all. Eclipse根本不将该项目视为项目。

  2. Create a java project first, and link it to the repo such that I can do push and pull to the repo . 首先创建一个Java项目,并将其链接到仓库,这样我就可以推入和拉出仓库 No idea how. 不知道如何。

Any help would be hugely appreciated. 任何帮助将不胜感激。

For option 1/, it could be as simple as to add the Java Nature to your current project (as seen also here ). 对于选项1 /,可能就像将Java Nature添加到当前项目中一样简单(也请参见此处 )。

Regarding the option 2/, you could create your java project, and then: 关于选项2 /,可以创建Java项目,然后:

  • delete the project from your workspace (soft delete only, you wouldn't delete the files on the hard drive) 从工作空间中删除项目(仅软删除,不会删除硬盘驱动器上的文件)
  • move the project files (ie .the .project, .classpath and sources) to the local git repo 将项目文件(即.project,.classpath和源代码)移动到本地git repo
  • import that project (in its new location) in your Eclipse workspace. 将该项目(在新位置)导入Eclipse工作区中。
  • right click on them, select Team-> Share-> Git (and select your Git repo location), in order to mention to Eclipse that this project is managed by Git. 右键单击它们,选择Team-> Share-> Git (然后选择您的Git存储库位置),以便向Eclipse提及该项目由Git管理。

I think importing the repository into Eclipse and running the project are different things. 我认为将存储库导入Eclipse和运行项目是不同的事情。

To simplify the process, I always use "git clone xxx" to get a local repository. 为了简化过程,我总是使用“ git clone xxx”来获取本地存储库。 Then add an existing local git repository into Eclipse and create an existing java project from the cloned git repository respectively. 然后将现有的本地git存储库添加到Eclipse中,并分别从克隆的git存储库中创建一个现有的Java项目。 In this way, I can run my project and control the repository. 这样,我可以运行我的项目并控制存储库。

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

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