Download, install and configure the Maven local repository

1. Download the Maven installation package : Maven – Download Apache Maven

Choose to download and install the compressed package

2. Configuration environment

Right click on this computer , select properties , advanced system configuration , environment configuration , select new , enter the variable name and variable value (the upper directory of bin)

Click path and add %variable name%\bin to path

 

Check whether the Maven environment is configured successfully. Windows key + R, enter the cmd command, enter  mvn -v  , and the installed version appears, which means the configuration is successful.

3. Create a folder as a folder for maven to store jar packages

4. Modify the Maven configuration file , open the Maven directory, under conf , right-click to open settings.xml , and enter the editor

Add the local warehouse path (open to the folder where the Maven jar package is created and copy it)

Modify the first part: add local warehouse

Copy <localRepository>/path/to/local/repo</localRepository> and modify it to the path of the folder just created to store the Maven jar package

  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->

<!--修改第一部分:添加本地仓库-->
<localRepository>D:\maven\package</localRepository>

Modify the second part: add Alibaba Cloud image

Find the <mirrors> tag and add the following code inside

<mirror>  
    <id>alimaven</id>  
    <name>aliyun maven</name>  
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <mirrorOf>central</mirrorOf>          
</mirror>

Modify the third part: add the jdk version of maven (optional)

Add the following code inside the <profiles> tag

<profile>
    <id>jdk-1.8</id>
    <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
    </activation>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
    </properties>
</profile>

5. Add JDK

 6. Add Maven configuration

7. Set every time you open/create a project, select the Jar package storage warehouse to default to the local warehouse configuration

File -> Close Project -> Customize -> All Settings ->Build,.... -> Maven, operate according to the diagram

 

Guess you like

Origin blog.csdn.net/qq_53376718/article/details/130630516