Maven environment setup and required configuration and a brief introduction

Recently, the project has been completed, and I have some free time to review my previous knowledge in order to apply it more effectively in the future. I decided to start with Maven, then build an SSH + MyBatis framework, and finally finish the Hadoop distribution-related tasks.

Before installing any tools, I first configured the relevant environment variables on my computer. This is a crucial step to ensure that everything runs smoothly later.

First, I set up the Maven environment. The download link for Maven is available here (for Windows, choose the Binary zip version). After downloading, I extracted the Maven archive and configured the environment variables. To do this, I went to "Computer" > "System Properties" > "Advanced System Settings" > "Environment Variables." Then, I created a new system variable called M2_HOME and set its value to the path where I extracted Maven, such as E:\apache-maven-3.2.5. Next, I added %M2_HOME%\bin to the PATH variable so that the system can recognize the mvn command. Finally, I opened the command prompt and typed 'mvn -v' to check if the installation was successful.

Maven environment setup and introduction

Next, I changed the local repository location for Maven. By default, it's stored in the user directory under .m2/repository, but I prefer to store it on another drive to manage space better. I configured it to be located at E:/m2/repository. Then I opened the command prompt and ran 'mvn help:system' to download some basic information and verify that the configuration was working correctly.

Maven environment setup and introduction

Then, I configured the Maven plugin in Eclipse. I started by opening Eclipse and going to Help > Install New Software > Add. I entered the name 'm2e' and the location URL. However, since the original site might be down, I downloaded the plugin from my Baidu Netdisk. After extracting the ZIP file, I copied the contents of the features and plugins folders into the corresponding directories of my Eclipse installation. Once done, I restarted Eclipse.

Next, I configured the user-level settings.xml file. The global settings.xml file is located at %M2_HOME%/conf/setting.xml, which affects all users on the machine. To avoid affecting others, I copied this file to my own repository, such as F:/m2/setting.xml.

I also set the MAVEN_OPTS environment variable to prevent OutOfMemoryError when working with large projects. There are two ways to do this: either edit the mvn.bat file in the Maven bin directory and add 'set MAVEN_OPTS= -Xms125m -Xmx512m', or set the variable directly in the system environment variables with the same values.

Maven environment setup and introduction

Finally, I configured Eclipse to use the correct Maven installation. I went to Window > Preferences > Maven and selected the installed Maven directory. I made sure to uncheck the default Maven and add my custom one. This ensures that Eclipse uses the correct version of Maven for my projects.

PWM Solar Charge Controller

Pwm Solar Charge Controller ,Pwm Charge Controller,Go Power Solar Controller,Prostar 30 Solar Charge Controller

zhejiang ttn electric co.,ltd , https://www.ttnpower.com