Environment variable configuration of maven for mac

First download the maven file
Download and install

Download address: Maven – Download Apache Maven

insert image description here

2. Configure environment variables

Open the mac terminal and enter the command directly without any operation:vim ~/.zshrc

After opening .zshrc, press the i key to configure as follows:

#maven
export MAVEN_HOME=/Library/Maven #这里的路径是根据自己的电脑存放maven的路径进行配置
export PATH=$MAVEN_HOME/bin:$PATH

Press esc to exit the editing state, enter: wq!, exit the file

Execute the effective command in the terminal:

source ~/.zshrc
and execute the command:

mvn -v

If information such as the version of maven is displayed, as shown in the figure below, it means that the configuration is successful.

insert image description here

We can find the following configuration directly, and directly modify the setting.xml file of maven's conf

  1. Configure mirroring

Under the path that maven comes with (due to being blocked by a wall, etc.), the download speed of many of our guide packages may be very slow. In order to once and for all, we directly configure maven with a mirror image to speed up the download.

First, you need to find the maven folder under the configuration path, find the settings.xml file in the /conf folder, open it with a text editor, and configure the image of Alibaba Cloud under the image example given.

The specific configuration code is as follows

<mirror>
  <id>nexus-aliyun</id>
  <mirrorOf>*,!jeecg,!jeecg-snapshots</mirrorOf>
  <name>Nexus aliyun</name>
  <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

The original code is:

<mirror>
      <id>maven-default-http-blocker</id>
      <mirrorOf>external:http:*</mirrorOf>
      <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
      <url>http://0.0.0.0/</url>
      <blocked>true</blocked>
    </mirror>

  1. Configure local warehouse

Open the installed maven directory

Enter conf–>edit the settings.xml file

Modify <localRepository>

Find and modify <localRepository>, originally commented out, you can uncomment it <localRepository>The local warehouse path you want to store</localRepository>

Line 53, change to:

/Library/Maven/repo

The original code is: /path/to/local/repo

And create a new repo folder under the /Library/Maven folder

Guess you like

Origin blog.csdn.net/weixin_58276266/article/details/130919850