Eclipse and M2E Plugin

Eclipse and M2E Plugin

If you are a Java developer and use the Eclipse JEE version as your primary IDE and your project is using Maven, you would have to install the Maven 2 Eclipse (M2E) plugin into Eclipse in order to integrate Eclipse with the Maven install on your machine.

This post will show you to install and configure the M2E plugin.

M2E can be installed via the Help -> Install New Software within Eclipse.

The update site url for the M2E plugin : http://download.eclipse.org/technology/m2e/releases

Once you have installed the M2E plugin and restarted Eclipse, ensure you configure the following, for Eclipse to be integrated with Maven correctly:

1. Within Eclipse, go to Preferences -> Maven -> Installations
2. Add an external installation by clicking on the Add button and browsing to the folder where Maven is installed on your machine.
3. This will ensure that you will always use the Maven that you have installed on your machine (and not the embedded one in Eclipse) and the configurations will be the same, irrespective of how maven is used i.e either via command line or from within Eclipse.
4. You will notice that by pointing Eclipse to the Maven install folder, it will automatically pick up the setting.xml file from under the conf folder of the Maven install.
5. Here is a screen shot of the added Maven install after the above steps are completed:

Maven_Install

6. Next click on the Preferences -> Maven -> User Settings option
7. Browse and select the settings.xml file, from the conf folder of the Maven installation that you added in the previous step.
8. This will ensure that there will be one and only one Maven local repository on your local machine. This is one of the configurations that is done in the setting.xml file. By selecting the same setting.xml file, you now ensure that Maven works the exact same way, inside Eclipse and outside Eclipse on its own.
9. This is the screen shot of the User Settings tab, pointing to the correct settings.xml file and the Maven Repository

Maven_UserSettings

10. You can select the ‘Update Maven Projects on Setup’ option under Preferences -> Maven tab. This will ensure that the Maven Dependencies are updated automatically when Eclipse starts up.

Once you do the above settings, rest assured that the Maven projects will always work correctly.

Do let me know if you run into any issues while setting this up.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

code