简体   繁体   中英

How to configure a project imported from GIT to be a Java project in Eclipse?

I've imported a project from Git in Eclipse using this method: File > Import > Git > Projects from Git > Next > Clone URL .

At this point I inserted the URI like this https://github.com/mygituser/My-Project . Then my user and password, and the project was imported.

The problem is that Eclipse didn't recognize it as a Java project, and I really don't know why.

As consequence, I can't see errors or warnings on my project and neither use autocomplete, I'm getting this message "This compilation unit is not on the build path of a Java project".

Also, right click on My-Project > Build path shows the message "No actions avaliable".

If you need more information to help me, could you ask me on comments, please? I appreciate your attention!

Most people don't include build files in repositories, only source. What you need to do is create a new Eclipse project the create a Git repo on top of that:

  • Create a new Eclipse project, and go to it with your terminal.
  • git init to initialize a repo.
  • git remote add origin https://github.com/mygituser/My-Project to add the remote.
  • git pull -u origin master to pull the changes.

Also, make sure that when you commit, you don't add build files that the author kept out. You can do this via a .gitignore file. Simply take this file and add it to your project directory.

This method applies to most Git repositories, as build and compiled files are usually left out.

Note that this method requires that you install Git for command line (or Git Bash). You can get Git at their website .

由于您已经从git存储库下载了源代码,因此您应该能够从现有源代码创建Eclipse项目。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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