Install the Maven plugin in Eclipse

In fact, in the latest downloaded Eclipse, the Maven plug-in has actually been integrated, but the version may not be the latest.

Step 1: Download Maven

Visit the Maven official website and find "Download" in the menu bar:

In the opened page, find the download location, and you can download different compressed formats according to different needs:

After the download is complete, decompress the compressed package and place the directory obtained after decompression in a proper location:

Step 2: Create a local warehouse

The "local warehouse" is just a directory on the computer, which can be in any location you like.

In fact, it's best if you have an "ancestral local repository" where you can remember the directory location of that local repository. If you don't have a local warehouse, you can create a folder in your own directory as a local warehouse. Maven will download the .jar file to the local warehouse for development:

Step 3: Configure Maven

Go back to the Maven directory downloaded and decompressed in the first step, find the "conf" folder, enter it, and open the "settings.xml" file with a text editor:

In this file, find the "localRepository" configuration item. If Maven is downloaded for the first time, this part of the configuration item is likely to be commented out by default. Find it, and change it to the directory path of the local repository you created in step 2:

Note: Chinese should not appear in the path

After completion, also in this file, find the "mirrors" configuration. In this configuration item, you can add multiple Maven mirror download addresses:

<!-- 中央仓库1 -->
<mirror>
    <id>repo1</id>
    <mirrorOf>central</mirrorOf>
    <name>repo1.maven.org/maven2</name>
    <url>https://repo1.maven.org/maven2/</url>
</mirror>

<!-- 中央仓库2 -->
<mirror>
    <id>repo2</id>
    <mirrorOf>central</mirrorOf>
    <name>repo2.maven.org/maven2</name>
    <url>https://repo2.maven.org/maven2/</url>
</mirror>

<!-- 阿里镜像 -->
<mirror>
    <id>alimaven</id>
    <name>aliyun maven</name>
    <!-- https://maven.aliyun.com/repository/public/ -->
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <mirrorOf>central</mirrorOf>
</mirror>

Note: The above code needs to be configured between "<mirrors>...</mirrors>"

If you don't need to perform daily Maven operations on the operating system command line, then the above configurations are relatively fine.

Step 4: Install the Eclipse plug-in

Open the Eclipse application market, search for "Maven", download and install the "Eclipse m2e" plug-in:

By default, the Eclipse downloaded now generally has the plug-in pre-installed.

If the above m2e plug-in has been correctly installed (or pre-installed), continue to open the "Preferences" of Eclipse, find the "Maven" menu, find the "Installation" option under it, and click the "Add" button to add the above first step Add the downloaded Maven to it, remember to click "Apply" to make the configuration take effect:

 Do not close this "Preferences" dialog box, continue to click on the "User Settings" secondary menu in the "Maven" menu item on the left:

 Then on the right side, in the "Global Settings" item, click the "Browse..." button to select the settings.xml file edited in the third step above and located in the conf directory of the Meven path:

Then, in the "User Settings" item, click the "Browse..." button to select the settings.xml file in the local warehouse in the second step above (if not, you can copy the Global Settings file):

If in this window, you see that the "Local Repository" below is automatically recognized, it means that the setting is successful. If it is not automatically recognized, you can try to click "Reindex" on the right:

 it's all done here

Guess you like

Origin blog.csdn.net/freezingxu/article/details/122769650