Pit father’s maven

Maven has not been used before. Recently, when studying cursor, I imported other people's projects, but there is no corresponding package. Maven needs to be used to solve the dependency. So all kinds of tosses were finally solved, but there were still many pits in the middle. Although there are corresponding installation tutorials on the Internet, many of them are vague and ambiguous. Finally, they decided to sort them out by themselves.

1、 Download Maven and configure the relevant environment variables

The download address is as follows:

http://maven.apache.org/download.cgi#

Unzip and set environment variables. There are two main settings: Maven_ Home and path. Take my local settings as an example.

MAVEN_ HOME:E:\apache-maven-3.3. nine

Path: add after path;% MAVEN_ HOME%\bin。

Execute MVN - V in DOS window to see if there is output. The normal output is as follows:

Note: if there is no output, you may need to restart the computer for the environment variables to take effect.

2、 Set Maven's profile settings xml。

The file is in the conf directory.

There are two modifications:

1. Maven's default file saving path

Maven's default file saving path is ${user. Home} / M2 / repository, ${user. Home} refers to the home directory of the current user

Here, I change it to the E: \ Maven directory of this machine.

2. Modify Maven's image source

Here, it is recommended to use the image source of open source China

Modify the mirrors section as follows:

For other settings, please refer to "open source China Maven library help"

http://maven.oschina.net/help.html

It has ready-made settings XML, just modify the Maven default file saving path.

3、 Installing the eclipse Maven plug-in

There are two popular installation methods on the Internet, one is online installation, the other is offline installation.

For offline installation, refer to: http://blog.csdn.net/guanning0109/article/details/26069277

eclipse-maven3-plugin. The download address of 7z is: http://download.csdn.net/detail/bluerebel/7407455

I prefer to try offline installation. Unfortunately, after restarting eclipse, Maven's plug-in does not appear in "preferences".

Finally, I was helpless. I adopted online installation and found that online installation is still quite simple without the various deficiencies mentioned in the above blog.

Install Maven plug-in Online

Click Install new software under help and enter the address: http://m2eclipse.sonatype.org/sites/m2e/ Next, select accept with the license, wait for the installation, and restart eclipse.

For details, please refer to: http://jingyan.baidu.com/article/e6c8503c1d04d3e54f1a1807.html 。

One step is missing from the above reference documents, that is, after restarting eclipse, you need to set the Maven plug-in to associate with the previously downloaded Maven software. Set in preferences under window.

After the above installation, the eclipse Maven plug-in is installed~

In this way, Maven dependency can be solved online.

Summary:

Looking back, the whole process is quite simple, mainly in two places:

1、 At the beginning, the official default image source was used. After downloading all kinds of pits for a long time, only one JUnit was downloaded. If you repeatedly execute "update dependencies", the following errors will be reported:

Solution: modify Maven's mirror source.

Practice has proved that after changing Maven's image source, the download is smooth.

2、 Maven may have downloaded during the download process, but the download was unsuccessful, or a directory has been created before. At this time, brush POM The XML file will still report an error, as shown below:

Although the download is smooth, several packages still can't be downloaded.

Solution: delete the corresponding directory and brush POM again xm

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>