Windows installation maven+idea configuration maven

Summary:

Edible notice: Before installing maven, our computer must have installed the java jdk environment in advance. If it is not installed, you can install jdk first. You can watch the tutorial of installing jdk online, or refer to my blog ( Windows installation jdk8 detailed tutorial +Download address_Boy who loves to knock code's blog-CSDN blog )

Note: When installing maven, it needs to be compatible with the version of jdk, so when installing maven, we can go to maven's official website (Maven – Download Apache Maven ) to check the compatibility relationship between maven and jdk

 1. Download maven

1. Download maven from the official website

 The author chose 3.8.3. Binaries must be selected here, which have been compiled.

 2.Alibaba network disk download

Address: Alibaba Cloud Disk Sharing

Extraction code: 6y3y

Friendly reminder: the configuration file in this folder has been modified, you only need to modify it according to your configuration to use it.

It is valid forever. This is a file that has been decompressed. Ready to unzip

2. Configure environment variables

1. Create new environment variables

Right-click this computer-->Properties-->Advanced system settings-->Environment variables-->New system environment variables

Variable name: MAVEN_HOME

Variable value: the path of the decompressed maven

Customize settings according to your own

 2. Edit the Path of the system environment variable

Add the following environment variables: %MAVEN_HOME%\bin

 Click OK one by one to close the window, otherwise your configuration will not take effect.

3. Verify whether the maven environment is configured successfully

Open the command prompt window (shortcut key: Windows+R) and enter cmd

Enter the command: mvn -version to see the version information of maven after the installation is successful

 3. Configure maven warehouse

1. Create a new local warehouse at the same level as maven

2. Find the settings.xml file  under conf in the maven decompression directory

 3. Open the settings.xml file to configure your own warehouse address <localRepository>

4. Configure mirroring (Ali mirroring) <mirrors>

Purpose: If you do not configure it, downloading dependencies from abroad will be relatively slow, but downloading dependencies domestically will be much faster.

 <!-- 阿里云仓库 -->
    <mirror>
      <id>aliyunmaven</id>
      <mirrorOf>*</mirrorOf>
      <name>阿里云公共仓库</name>
      <url>https://maven.aliyun.com/repository/public</url>
    </mirror>

 Add in the following location:

 5. Configure jdk

Find the <profiles> node in the settings.xml configuration file

<!-- java jdk1.8版本 -->
    <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>

 At this point, the configuration is complete. Run cmd with win+R and enter the command: mvn help:system to test. If the configuration is successful, the local warehouse will be displayed as shown below.

 4. Configure maven globally in idea

This purpose is to avoid the need to manually modify the maven path every time you create a new maven project, and set it in the idea2023 version.

Follow the steps below: configure.

If it still doesn't work after installing the following settings once, just set it up a few more times.

 At this point, the configuration of maven in idea is over.

Reference: The most detailed Maven installation tutorial in history_mvn installation_chenxiky's blog-CSDN blog

Guess you like

Origin blog.csdn.net/m0_52985087/article/details/132295994