Install Maven and its Eclipse plug-in m2eclipse
(This article references Maven practices)
Check JDK installation and environment variable configuration
Open cmd
Echo % java_home %
Java-version
For example
Download Maven
Http://maven.apache.org/download.html
The latest version 3.03 is installed here.
Install on Local Machine
1 decompress the downloaded package to any address, my path is D: \ Program Files \ apache-maven-3.0.3
2 new environment variable m2_home points to D: \ Program Files \ apache-maven-3.0.3
3 add % m2_home % \ bin at the end of Path
4. Check whether the installation is successful.
Open cmd
Echo % m2_home %
Mnv-V
For example:
Install Maven plug-in m2eclipse for eclipse
1 open eclipse
2 help-install new software appears
3. Click Add.
Enter m2e in name
Enter http://m2eclipse.sonatype.org/sites/m2e in location
4. After confirmation
5 check Maven integration for eclipse
6. continue to the next step until the installation is complete.
7. Check whether the installation is successful.
(1) Click Help-about eclipse-installation details to check whether Maven integration for eclipse (required) exists, for example:
(2) Check whether eclipse can create a Maven project.
File-New-other
Configure the location of the local repository
First, read the following note: (1)
WeProgramThe required jar package will be found in the local repository first. If it cannot be found, it will be downloaded from the central repository on the network. Of course, the local repository is placed under the user of drive C by default. m2 folder, which can be opened here. m2 settings. modify XML
Find the following
Here we specify that the local repository is located in the mavenrepository folder of the d disk.
Configure Proxy Server
If many companies that do not have an Internet connection cannot access Apache's central repository, a proxy server is configured in the LAN.
Also in ~ Find the proxies node under settings. XML in the/. m2 folder.
<Proxies>
</Proxies>
You can configure multiple proxies under this node.
<Proxy>
</Proxy>
...
<Proxy>
</Proxy>
If you declare multiple proxy elements, the first activated proxy will take effect by default.
Specific Configuration:
<Proxy>
<! -- Unique identifier -->
<ID> my-proxy </ID>
<! -- Indicates whether the proxy is activated. For example, if there are multiple proxies mentioned above, the first activated proxy will be searched. -->
<Active> true </active>
<! -- Access through HTTP -->
<Protocol> HTTP </protocol>
<! -- Server IP Address -->
<Host> 218.14.227.197
<! -- Access port number -->
<Port> 3128 </port>
<! --
<! -- If the server needs to be verified, You need to configure the user name and password here -->
<Username> *** </username>
<Password> *** </password>
<! -- Create the domain names that do not need to be proxies -->
<Nonproxyhosts> repository.mycom.com | * .google.com </nonproxyhosts>
-->
</Proxy>
Note:
(1) We can copy settings. XML in the conf folder of the maven installation directory to ~ /. M2 directory (for example, the local machine is: C: \ Users \ Chacha \. m2 \), the settings of the former. XML affects the global scope, while the latter only affects the current login users. We recommend that you use the latter, which depends on the situation.
(2) Disable Maven embedded in eclipse
This embedded Maven is usually relatively new, but not necessarily stable, and is often different from the maven version we use on the command line. There are two potential problems: first, there are many unstable factors in the newer versions of Maven, which may cause some difficult-to-understand problems. Second, apart from IDE, we also often use maven of the command line. If the versions are inconsistent, the build behavior may be inconsistent, which we do not want to see. Therefore, we should use Maven that is consistent with the command line When configuring Maven plug-ins in IDE.
Solution:
Window-preferences-Maven-installations-add and select the installation directory and click Apply
(3) If you encounter the following prompt when using m2eclipse:
Eclipse is running in a JRE, but a JDK is required
Some Maven plugins may not work when importing projects or updating source folders.
This is because eclipse runs on JRE by default, while some functions of m2eclipse require JDK. The solution is to configure the eclipse. ini file in the eclipse installation directory, and add VM configuration pointing to JDK, as shown in figure
OK. All preparations have been completed !!!