Maven installation, configuration and IDEA integration
1 installation
1.1 Download and unzip:
Download address: https://maven.apache.org/download.cgi
Unzip to a custom folder (I renamed the folder after decompressing the compressed package to [ maven-3.8.2
] and placed it under the new [ apache
] folder , the total path of the installation directory is: [ D:\softwares\proapps\apache\maven-3.8.2
]):
1.2 Set environment variables
Create a new one in the system variable (S) MAVEN_HOME
:
Then set the path and create a new-> %MAVEN_HOME%\bin
verify command to see if the version information is output:mvn -v
2 Configure maven central warehouse and local warehouse
2.1 Create a new local warehouse
Create a new folder [ ] under apache
the folder maven-repository
as a local warehouse:
2.2 Configure settings.xml file
Open the file conf
under the folder settings.xml
(the text editor I use is notepad++)
and set the priority to use the local warehouse:
Extract the commented out local warehouse:
<localRepository>/path/to/local/repo</localRepository>
Change to the local warehouse folder created in the previous step:
<localRepository>D:/softwares/proapps/apache/maven-repository</localRepository>
Set the central warehouse
1. Comment out first The default central repository.
2. Place the Alibaba Cloud central warehouse into it. The code is given below.
Alibaba Cloud central warehouse URL query URL: https://developer.aliyun.com/mvn/guide . Find public
the url address of the warehouse name and put it in the settings file. 这里建议手写,并注意结构
.
Note: You can also use <mirrorOf>
labels to use the original central warehouse as a backup warehouse. It is of little use and will not be set here.
<mirrors>
<mirror>
<id>alimaven</id>
<mirrorOf>*</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
2.3 Copy the settings.xml file to the local warehouse
Just copy and paste the conf
files settings.xml
in the local warehouse folder.
3 IDEA integration
3.1 Import locally installed maven
The operation is as shown in the figure:
1. First find the maven configuration item.
2. Open the maven local installation directory.
3. Rewrite the settings file: Open the settings.xml file in the conf folder.
4. Load the local warehouse: open the local warehouse path.
3.2 When the dependencies in the pom are set to change, the project automatically downloads the required dependencies.
3.3 Refresh the project
Note: If you right-click the project and find that there is no Maven option. Then—— 右击pom.xml文件
. Add as Maven Project
_ Set the project as a maven project.