3

There are quite a few questions on this topic, but there are no satisfactory answers unitl now, e.g this.

I'm using Eclipse Kepler (20130529-2219), with ME2 (1.4.0.20130601-0317) and Eclipse Git Team Provider (Java implementation of GIT 3.0.0.201306040240-rc3). So I started with great expectations after reading how great git is.

Firstly, I opened an existing project and removed all the .svn rubbish and commited it to a local git repository. Perfect - now it is time to push the files to a remote repository. After having some problems creating the known_hosts file on Windows the push was successful.

Now the problems started: I wanted to pull changes for the repository, but "... not configured for pull". OK, here it was discussed that this is a common issue, and you have to delete the project and then reimport it from a remote server to allow pulling.

Hence, I set up everything again and pulled the project. Until now I was always told that .project files should not be commit to version control, therefore I didn't include them. The "import -> import from git -> local"-menu does not recognize the files in the repo as a Java project. I can therefore only import the project as a general project or use the project wizzard and set up a new Maven project, which is stupid because all information already exists in the POM.xml. If I do a plain project import, Eclipse does not know that it is a Java or Maven project and throws tonnes of errors.

Question (skip detailed problem): Is there some less awkward way to import a Maven and Java project from a remote git repo when no .project file exists?

4

2 回答 2

3

最简单的解决方案:在你的 git repo 中 包含.project(如this answer中)。

并且还包括.classpath, 因为您现在可以在其中引用相对路径,而不是绝对路径:请参阅“.classpath.project- 是否检查版本控制?

于 2013-06-23T11:26:57.033 回答
0

我找到了将 .project 文件排除在 Git 版本控制之外的替代方法。正如您所说, pom.xml 文件应该足以让 IDE 确定它是一个 maven 项目(它是)。

假设您已将项目推送到 Git(没有 .project 文件),现在您想将该项目导入 Eclipse。

  1. 确保您已将 Git 存储库添加到 Git 透视图中
  2. 转到 J2EE Perspective 并双击 Navigation View 上的空白区域。导入 -> 现有的 Maven 项目
  3. 浏览到您的 Git 存储库位置,瞧!Eclipse 应该捕获所有 pom.xml 文件并确定它们是独立的 Maven 项目

在我的情况下,这可以提取位于同一个 Git 存储库中的多个项目,每个项目只存储 pom.xml 文件(根本没有 .project)

于 2017-04-20T19:16:35.383 回答