Installing Apache Maven
Acquire the binary distribution from the official Apache Maven website and extract the archive contents to a dedicated directory on your system. For this demonstration, we assume the extraction path is D:\dev_tools\apache-maven.
System Environment Setup
To execute Maven commands from any terminal location, configure the environment variables:
- Create a new system variable named
MAVEN_HOMEand assign the value of your installation directory. - Edit the system
Pathvariable and append the Maven binary directory:%MAVEN_HOME%\bin
Validate the configuration by opening a command prompt and executing the version check:
mvn --versionMaven Configuration
Navigate to the conf directory inside your installation folder and open the settings.xml file. This file controls repository behavior and storage locations.
Local Repository Path
Define a specific location for storing downloaded artifacts to avoid using the default user home directory. Insert the following XML tag:
<localRepository>D:/maven_storage</localRepository>Remote Repository Mirrors
To improve dependency download speeds, configure mirrors within the <mirrors> section. The following example configures the Aliyun cloud repository:
<mirrors>
<mirror>
<id>aliyun-public</id>
<name>Aliyun Public Repository</name>
<url>https://maven.aliyun.com/repository/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>aliyun-spring-plugin</id>
<name>Aliyun Spring Plugin Repository</name>
<url>https://maven.aliyun.com/repository/spring-plugin</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>spring-milestones</id>
<mirrorOf>central</mirrorOf>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</mirror>
</mirrors>IntelliJ IDEA Integration
Link the configured Maven installation to the IDE:
- Open File > Settings > Build, Execution, Deployment > Build Tools > Maven.
- Set the Maven home path to your extracted directory:
D:\dev_tools\apache-maven - Update the User settings file path:
D:\dev_tools\apache-maven\conf\settings.xml - Verify that the Local repository field automatically detects the path specified in
settings.xml(e.g.,D:/maven_storage).