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]):
Insert image description here

1.2 Set environment variables

Create a new one in the system variable (S) MAVEN_HOME:
Insert image description here
Then set the path and create a new-> %MAVEN_HOME%\bin
Insert image description here
verify command to see if the version information is output:mvn -v
Insert image description here

2 Configure maven central warehouse and local warehouse

2.1 Create a new local warehouse

Create a new folder [ ] under apachethe folder maven-repositoryas a local warehouse:
Create a new folder as a local repository

2.2 Configure settings.xml file

Open the file confunder the folder settings.xml(the text editor I use is notepad++)
Insert image description here
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>
Insert image description here
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 publicthe 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.
Insert image description 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 conffiles settings.xmlin the local warehouse folder.
Insert image description here

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.
Integrate Maven into IDEA

3.2 When the dependencies in the pom are set to change, the project automatically downloads the required dependencies.

Insert image description here

3.3 Refresh the project

Insert image description here
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.

Guess you like

Origin blog.csdn.net/qq_38662733/article/details/120052908