Cannot import maven project in IntelliJ - java

When trying to open a maven project through the pom.xml, IntelliJ shows the windows: Open project, when I click open as project I can see the window: scanning maven projects. I can't get to the window open in current window or new window.
When I try to open a non-maven project, it opens it. When I try to open a maven project as a normal project it doesn't seem to do anything.
I have successfully opened a project as maven project through cloning it from Git, bit it gives me errors that it can't import the maven dependencies.
I can do mvn --version, mvn clean compile etc.
I have tried to open projects without the .idea folder and with the .idea folder. That didn't work.
I have reinstalled IntelliJ already.
EDIT: I am using IntelliJ version: 2018.2.4 Ultimate.
EDIT2: I just noticed that the blue color that usually appears by a pom.xlm is different, see screenshot.other color?

To import a maven based project in intellij Idea follow the following steps:
Open intellij idea,
Goto File menu,
Click on New,
Click on Project from existing sources,
Select file or directory to import,
Select POM file ,
Click on OK,
Finalize the other steps,
wait till the import loading gets completed(Sometime it takes much duration to complete)
Your project will get loaded with files and folder on left side.

Do you have an exception in your firewall so IntelliJ can make http requests?

Related

Unable to import Maven Project in Eclipse as Next and Finish buttons are disabled

Initially, I have imported Maven Project to eclipse then got deleted accidentally from Workspace, and delete project contents on disk were unchecked.
I tried to import the Maven project again to eclipse but facing Next and Finish buttons are disabled though have deleted .m2, .eclipse, .mc-ad, .p2 from the user's folder. There is no settings.xml in the Users folder.
I have installed Eclipse in another place also, and tried, but Observed the same behavior.
Could you please update me on how to import the Maven project again, if deleted from the workspace?
Eclipse Screenshot
Thanks for your support.
Project Screenshot
There is no Maven project (pom.xml) in the directory you are looking at. Change the root directory to the directory your project is in (in your case probably not the same as the workspace).

Import Java project from GitHub to Eclipse

I'm trying to import a project on GitHub into eclipse because there are a few things I want to add to it. However whenever I add it I get a ton of errors and problems with it...
The GitHub project is https://github.com/dmulloy2/SwornGuns
I've tried adding it to eclipse and it didn't work. I then tried making a project in eclipse and then put the files in, that didn't work. I also read online that going to Configure -> Convert to Maven Project would work, and then importing the spigot.jar file that this source depends on. However that didn't work and just gives me a ton of import errors.
The errors I am getting:
That project is a maven project. A simple way is clone that project into your machine, and import it as a maven project, with File - Import - Maven - Existing Maven Project.
Eclipse will help you resolve the pom file and configure project and download necessary libs.
First, make sure you are using Luna, the most recent version.
In eclipse, File > Import > Git > Projects from Git > Existing Local Repository.
In the Import Projects from Git screen, click add, then goto the location of the cloned repository. Click open, finish, then next. Select Java > Java Project, and click next again.
At this point, there are three options.
Import existing projects
Use the New Project Wizard
Import as General Project
Pick "Use the New Project Wizard". Then, uncheck "Use Default location", and click browse. Select a folder (You probably want the location you cloned the repo to), click "Open", and give the Project a name. Click next, and make sure that the src/bin folders are setup correctly, and click finish.
Whew!
Of course, the Import from Git option was only added in Luna, so update eclipse if necessary.

IntelliJ Idea opens gradle folder instead of the project

I'm trying to import a GitHub project, specifically, this one : timtiemens/secretshare using IntelliJ Idea.
The git import works fine, at which point the IDE builds the project using gradle, which works fine.
However, when I actually open the project, only the gradle directory in the project is opened, ie, .../secretshare/gradle. The other directories, like src, are just not there in the IDE, even though they're present in the project folder - I can see them with explorer.
Just Delete the idea files created by inteillj
Run gradlew idea
Open the project again and choose use gradle wrapper settings.

How do I open a Java project (that uses maven) in Eclipse? (Do I use M2E or maven-eclipse-plugin)

I'm trying to open this project in Eclipse but not sure how.
I followed the build instructions and not sure how I tell Eclipse to use Maven as the source control (if required) and then open the Java project so I can step through it.
I discovered that there are two Maven plugins for Eclipse (M2E and maven-eclipse-plugin) and not sure which one to choose, since they are incompatible with each other and I need to use.
From the OS command line, in the directory of the pom.xml file:
mvn eclipse:clean eclipse:eclipse
This will create the various eclipse project files. Then in eclipse, in the "Project" pane, right-click > "Import existing project" and navigate to the directory - you'll find it has recognised there's now a project to import.
This should work:
Right click in the Package Explorer, choose Import.
From the context-menu of the Package Explorer choose import.
In the now open panel search for Existing Maven projects. The rest is pretty much self explaining.

Errors after importing Maven project into Eclipse

I imported a Maven project into Eclipse. I was able to deploy it from the command line. In Eclipse it is full of red Xs. I have cleaned the project, updated the configuration and I ran the following command:
mvn -Declipse.workspace=<pathtoworksapce> eclipse:add-maven-repo
and I still have the same problem. The project is dependent on another project.
What I ended up doing was removing all of the projects in Eclipse, but not deleting the source files. Then instead of directly importing the code as Maven->Check out as Maven Projects with SCM, I selected Existing Maven Project and imported the code from my local machine. This got rid of the errors, but when I would right click on code and select "Open Declaration", I would get Error: Could not open the editor: The file does not exist" So I removed all projects again and this time I deleted all the ".project" files and repeated the import Existing Maven Project. So now there are no red Xs (dependency problems) and the lookup functionality within the code works.
Go to your master project and type the following :
mvn install
mvn eclipse:eclipse
After that, import your project. You can also install m2eclipse for better support. If you use gwt or any other framework which has a custom maven execution, you should also install plugins for those in Eclipse.

Categories