A detailed tutorial on installing and configuring Java JDK and Maven on Windows

The two parts of Java and Maven are independent tutorials, and readers can skip them as needed

1. Install Java JDK on Windows

①上oracle官网(Oracle | Cloud Applications and Cloud Platform

Resource->Java Downloads

Enter the java download interface. This article downloads Java8 JDK, so pull down the interface and slide to the Java8 download location.

②Choose Java8 windows 64-bit system version to download

Click in the order of the icons to download

③ After the installation package is downloaded, execute

Double-click the installation package to install

Enter the following interface, click Next

Change the jdk installation path , it is recommended not to put it on the drive C drive, so as not to occupy the drive disk space. click next

Click Next and wait for the installation to complete .

④Set Java environment variables

Click the windows icon in the lower left corner, and enter "environment variable" with the keyboard to open the environment variable editing window

Click on Environment Variables

Environment variables are divided into user variables and system variables, click New System Variables below

Add the JAVA_HOME system variable: the variable value is the installation path of jdk. This article is installed in D:\Java\jdk-1.8. Readers can modify their own installation path

Add the CLASSPATH system variable, the variable value is:

#注意:一定要把前面的.;拷上
.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar

Double-click to open the Path system variable

Newly add the following two variables

%JAVA_HOME%\bin

%JAVA_HOME%\bin

The effect is shown in the figure below

After the addition is complete, press OK to save the modification .

⑤ Open a new CMD window to check whether the installation is successful

If the above effect is displayed, the installation is successful!

Two, Windows installation Maven environment

① Download the installation package from the Maven official website ( Maven – Download Apache Maven )

The download on windows is a .zip compressed package . binary does not contain maven source code. source contains the source code, and the editor can read the source code information. Choosing any of the above will not affect the use of maven. This article installs the maven3.6.3 binary version .

Pay attention to the version correspondence between maven and Java JDK . The corresponding information can be seen in Maven Releases History. Version incompatibility will affect the normal use of maven. The Java version must be greater than or equal to the Java version recommended by maven.

To install the historical version of 3.6.3, click Maven 3 archives under Other Releases to enter the following interface.

Select Maven3.6.3 Download 3.6.3->binaries Enter the binaries folder and download apache-maven-3.6.3-bin.zip.

② After the download is complete, extract it to the file path you want to place

Unzip this article to the D drive

③ After decompression, enter the corresponding installation path to find the conf folder, and modify the settings configuration file

The modified information is as follows:

Search for localRepository and add the location of the maven repository . This article is under the .m folder under the D drive, and the created repository folder acts as a maven warehouse. Readers can create a maven warehouse at any location other than the drive disk, and just add the warehouse path to the settings configuration file as shown in the figure.

#将标签中的路径改为你的仓库路径 
<localRepository>D:\.m2\repository</localRepository>

Modify the mirror source, set the domestic Alibaba Cloud mirror, and copy the code below into the corresponding location according to the diagram.

     <!-- 国内阿里云镜像配置 -->
       <mirror>
       <id>alimaven</id>
       <mirrorOf>central</mirrorOf>
       <name>aliyun maven</name>
       <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
     </mirror>

After modifying the settings configuration file, save the modification.

④ Configure maven environment variables

Open the environment variable editor, click the windows icon in the lower left corner, enter the environment variable, and open it.

Create a new MAVEN_HOME environment variable in the location of the system environment variable. The variable value is the installation location of maven, and it can be taken to the parent level of the bin folder.

Double-click to open the Path system variable

Add the following variables to the new

%MAVEN_HOME%\bin

The effect is shown in the figure below

After the addition is complete, press OK to save the modification .

⑤ Open a new CMD command window, enter

mvn -version

Just check whether the installation is successful. If the maven version information is displayed, the installation is successful.

Of course, this is the completion of the Maven installation. If you want to use the maven information you configured in the editor, you need to further configure it in the editor to ensure that the settings and warehouse paths you set can take effect.

⑤Intellij IDEA uses Maven

File->Settings to open the editing interface

search maven

Edit the corresponding information as shown below

After saving, you can use the maven project normally, run the maven project, and the corresponding required dependency packages will be downloaded in the maven warehouse.

Guess you like

Origin blog.csdn.net/qq_46274911/article/details/132619660
Recommended