Windows configures Maven's local warehouse and Alibaba Cloud remote central warehouse

Set up Maven's local repository

The default address of Maven's local warehouse is located in the C:\Users\username.m2 directory. The volume of the jar package in the warehouse will become larger with the iteration of the project, so I switched the address of the warehouse to the E drive. The specific steps as follows

download maven

Download address: http://maven.apache.org/download.cgi

I downloaded the zip compressed file, as shown below:
insert image description here

Then unzip it, I unzip it to the E drive
insert image description here

Configure environment variables

Click on My Computer -> Properties
insert image description here

Click on Advanced system settings
insert image description here

Click on Environment Variables
insert image description here

Create a new MAVEN_HOME in the system variable, the variable name is

MAVEN_HOME

The variable value is the decompression path just now:

E:\Program Files (x86)\apache-maven-3.8.4\

insert image description here

Double click path in system variable

add in path

%MAVEN_HOME%\bin

Click OK to save
insert image description here

Verify that the installation was successful

win+R to open the console, enter mvn -v, if the following figure appears, the installation is successful
insert image description here

Configure local repository

Open the maven decompressed file and find the settings.xml file under the config directory

Modify the address of the local warehouse to E:\Program Files (x86)\apache-maven-3.8.4\repositoryadd the following code:

<localRepository>E:\Program Files (x86)\apache-maven-3.8.4\repository</localRepository>

insert image description here

Check if the configuration just now takes effect

Enter in the cmd console

mvn help:system

When the console shows build success, check the maven_repos folder of the D drive again. There are many more files, indicating that the configuration takes effect.

insert image description here
In this way, the local warehouse is successfully configured.

Set up the maven remote repository

Maven's default remote address is

http://my.repository.com/repo/path

Because this address is a foreign website, the speed of downloading the jar package will be very slow. Here I use the address of Alibaba Cloud

Open the maven decompressed file and find the settings.xml file under the config directory
insert image description here

Add the address of Alibaba Cloud in the settings.xml file

<mirror>
  <id>aliyunmaven</id>
  <mirrorOf>*</mirrorOf>
  <name>阿里云公共仓库</name>
  <url>https://maven.aliyun.com/repository/public</url>
</mirror>

insert image description here

Check if the configuration just now takes effect

Type in the console

mvn help:system

When build success appears on the console, the configuration takes effect
insert image description here

Configuring Maven in IntellIJ IDEA

左上角File -> Other Settings -> Default Settings

Find Maven, and change to local configuration:
insert image description here
also check the automatic import
insert image description here

Another: The above is the default configuration of the change, if the project has been introduced, then change the File->Settings...

Guess you like

Origin blog.csdn.net/weixin_45525272/article/details/123608206