I want to import existing Maven project into Eclipse. I found 2 ways to do it:
mvn eclipse:eclipse
What is the difference between the both and which one is preferable?
If I install Maven Eclipse plugin through the Eclipse menu Help -> Install New Software, do I still need to modify my pom.xml
to include the Maven Eclipse plugin in the plugins section?
Since Eclipse Neon which contains Eclipse Maven Integration (m2e) 1.7, the preferred way is one of the following ways:
.project
) as well as for non-Eclipse projects that only contain the file pom.xml
.I find the m2eclipse plugin to be more useful. This provides nice tools like the POM editor and creating a Maven project from within Eclipse.
Maven have a Eclipse plugin and Eclipse have a Maven plugin we are going to discus those things.when we using maven with those command line stuffs and etc when we are going through eclipse we don't want to that command line codes it have very much helpful, Maven and eclipse giving good integration ,they will work very well together thanks for that plugins
Step 1: Go to the maven project. Here my project is FirstApp.(Example my project is FirstApp)
There you can see one pom.xml file, now what we want is to generate an eclipse project using that pom.xml.
Step 2: Use mvn eclipse:eclipse command
Step 3: Verify the project
after execution of this command notice that two new files have been created
Note:- both these files are created for Eclipse. When you open those files you will notice a "M2_REPO" class variable is generate. You want to add that class path in eclipse, otherwise eclipse will show a error.
Step 4: Importing eclipse project
File -> Import -> General -> Existing Projects in Workspace -> Select root directory -> Done
File » Import » Maven » Existing Maven Project » Next
http://www.websparrow.org/misc/how-to-import-maven-project-in-eclipse
I was unable to import a Maven project with the steps suggested above until I figured out why it was not importing:
A maven project will not import if you have another Maven project with the same artifact id. Make sure that your project's artifact ID is unique in your eclipse workspace.
Using mvn eclipse:eclipse
will just generate general eclipse configuration files, this is fine if you have a simple project; but in case of a web-based project such as servlet/jsp you need to manually add Java EE features to eclipse (WTP).
To make the project runnable via eclipse servers portion, Configure Apache for Eclipse: Download and unzip Apache Tomcat somewhere. In Eclipse Windows -> Preferences -> Servers -> Runtime Environments add (Create local server), select your version of Tomcat, Next, Browse to the directory of the Tomcat you unzipped, click Finish.
Window -> Show View -> Servers Add the project to the server list
I am not experienced with Eclipse or Maven so the other answers seemed a bit over complicated.
The following simpler set of steps worked for me:
Prerequisite: Make sure you have Maven plugin installed in your Eclipse IDE: How to add Maven plugin to Eclipse
pom.xml
file)Source: Stackoverflow.com