Download and configure the Maven warehouse under MacOS and related configurations in IntelliJ IDEA

Download and configure the Maven warehouse under MacOS and related configurations in IntelliJ IDEA

Welcome to this tutorial on configuring Maven repository on Mac system.

The first thing to declare is that the author is a pure novice who uses the Mac system, and has been greatly hindered by the use of the Mac terminal and related use. When looking up various tutorials on the Internet, I also encountered many incomprehensible problems, and properly solved them. Later, in order to let Xiaobai like me avoid detours, I specially published a tutorial, hoping to be useful.

About Maven download

Maven download address
https://maven.apache.org/download.cgi
Insert picture description here
We choose to download the binary file indicated in the figure
(the first line is the download method of MacOS and Linux, the second line is the download method of Windows, readers must Be careful not to download wrong)

After downloading, the compressed package is obtained. After decompression, it is shown in the figure below. Insert picture description here
In order to comply with the storage specification, we put this folder in
/usr/local-as shown in the figure
Insert picture description here

Configure Maven repository

To ensure the correct use of maven, we first configure the environment file

1) Check whether there is an environment configuration file in the directory, that is, the .bash_profile file. Go to the upper left corner of the visit page-go to the folder-enter ~/
Insert picture description here
Insert picture description here
As you can see from the picture, there is no .bash_profile file in the author's folder, so we need to create one, namely Run terminal input

touch ~/.bash_profile

Insert picture description here

As shown in the figure
, it is found that the file is generated. The author suggests that if a .bash_profile file is found in the folder, to prevent unnecessary trouble, delete the file and re-create it.
Then type in the terminal

vi ~/.bash_profile

After opening the configuration file, enter as shownInsert picture description here

Be sure to remember that the file location here must be the same as the path in Maven/bin just now, otherwise the configuration will be invalid

After pressing esc, the terminal will flash, and then enter the terminal
:wq
Insert picture description here
as shown in the figure and press Enter to force save.
Reopen the terminal and enter
source ~/.bash_profile
to run the configuration file. After
all the steps are completed, the
mvn -vInsert picture description here
above words in the terminal input indicate the Maven configuration Succeeded

Create Alibaba Cloud image


/usr/local/apache-maven-3.6.3/conf
Find the settings.xml file in the maven folder just now and
open it with a text editor and find the context as shown in the figure.
Insert picture description here
Add the code in the box to use Alibaba Cloud mirroring for fast loading

 <!-- 阿里云仓库 -->
	<mirror>
	 <id>alimaven</id>
	 <mirrorOf>central</mirrorOf>
	 <name>aliyun maven</name>
	 <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
	</mirror>

After saving, close text editing

Maven configuration in IntelliJ IDEA

打开IntelliJ IDEApreference->Build->Build Tools->Maven

Insert picture description here

Insert picture description here
As shown in the figure above, load the address of the Maven folder and the settings in the two boxes on the right.
Take the author as an example.

/usr/local/apache-maven-3.6.3
/usr/local/apache-maven-3.6.3/conf/settings.xml

Can be tested after loading

test

Insert picture description here
We can create a Maven project.
Insert picture description here
Insert picture description here
Insert picture description here
Select the Maven version. After this window is opened, it will automatically add the dependencies required by Maven

Insert picture description here
If successful after subsequent loading, it means

Congratulations, you have mastered Maven Run

Some tips at the end of the article

In order to ensure that there will be no big mistakes when running Maven, you can download the plugin Maven Helper in the plugin in IDEA
Insert picture description here

At the same time, if the loading timeout or failure for a long time when importing the warehouse, it is very likely that the Alibaba Cloud mirror configuration error or the library file error, be sure to pay attention

Insert picture description here

If it doesn't work, we can also refresh by clicking Maven on the right to find the refresh button.
Look forward to improvements after the refresh.

Author: Chen Bing yunshangjin
-mail: [email protected] can send e-mail consultation

Guess you like

Origin blog.csdn.net/yunshangjin123/article/details/113000962