(Super detailed) Maven installation, configuration and use IDEA to create Maven projects

Insert picture description here

One, Maven installation and configuration

Two, configure the Maven environment in IEDA and create a Maven project

I won’t talk about maven or java development first, let’s talk about cooking

For example, you might like to make a braised pork ribs (HongshaoxiaopaiApp), the materials you need are:

  1. Spare ribs (paigu.jar), to be a little pig (version=little pig).
  2. Soy sauce (jiangyou.jar), soy sauce for 82 years (version=1982)
  3. 盐(yan.jar)
  4. Sugar (tang.jar), sugar must be made in Guangdong (version=guangdong)
  5. Ginger (shengjiang.jar)
  6. Fennel (huixiang.jar)

So, you have to go to the vegetable farm to buy spare ribs, go to the grocery store at the door to buy soy sauce, buy salt... Maybe the grocery store at your door does not have the soy sauce of 1982, you have to go to the farmer’s market 3 kilometers away to buy... you buy raw materials The process is estimated to be painful, and the materials that may be purchased are not 1982, which will affect the taste.

Before you formally start making ribs, you will be half busy with the ingredients.

Now there is a boxed version of semi-finished braised pork ribs in a supermarket. The raw spare ribs, 1982 soy sauce, salt, sugar from Guangdong and other ingredients are packed into a box. You just need to follow the instructions to get the braised pork ribs. The ribs are made without considering the source of the material.

Maven is the supermarket. Braised pork ribs is the software you want to develop. Soy sauce and salt are the jar packages you need to develop software. We know that it is normal to develop a java system and download a bunch of jar package dependencies. With maven, you don't need to download various versions of jar packages from various websites, and you don't need to consider the dependencies of these jar packages.

Maven will do it for you, that is, the side dish master at the supermarket will help you match the ingredients for the braised pork ribs.

Now everyone should understand what Maven does.

Maven is a project management tool that can build and depend on Java projects.

1. JDK (Maven requires jdk1.7 or above)

1.1 Install jdk (download from official website)

Download link: https://www.oracle.com/java/technologies/javase-downloads.html

1.2 Configure the environment variable JAVA-HOME

The variable value is the path of the installed jdk

例:C:\Program Files\Environment\Java\jdk-15.0.1
Insert picture description here

1.3 Configure environment variable path

The variable value is the path of the bin under the installed jdk

例:C:\Program Files\Environment\Java\jdk-15.0.1\bin
Insert picture description here

1.4 Check version

Open the DOS interface, check the version "win+R" and enter "cmd", enter "java -version" in the interfaceInsert picture description here

2. Download Maven and configure its environment variables

2.1 Download address: https://maven.apache.org/
2.2 Configure Maven environment variables

After decompression, configure the root directory of Maven to the system environment variable MAVEN-HOME, and configure the bin directory to the path variable.

2.3 Check if Maven is installed successfully

Open the DOS interface, "win+R" and then enter "cmd", enter "mvn -version" in the interface
Insert picture description here

3. Configure Maven's setting file

Open the maven directory -> conf ->setting.xml

3.1 Local warehouse location modification

<localRepository> The address of the local repository you created
<localRepository>
Insert picture description here

3.2 Replace Ali's mirror to speed up dependency download

Also open the setting.xml file, find the <mirrors> tag node, and add Alibaba Cloud private server to this tag

< mirror >
​< id >alimaven</ id >
< mirrorOf >central</ mirrorOf >
< name >aliyun maven</ name >
http://maven.aliyun.com/nexus/content/repositories/central/
</ mirror >
或者
< mirror>
< id>nexus-aliyun< /id>
< mirrorOf>central< /mirrorOf>
< name>Nexus aliyun</ name>
< url>http://maven.aliyun.com/nexus/content/groups/public< /url>
< /mirror>

Insert picture description here

4. IDEA editor integrated with Maven environment

Open IDEA and select "File" -> "Other Settings" -> "Settings for New Projects..." to Insert picture description here
configure related content
Insert picture description here

To
Insert picture description here

5. Create a Maven project

1. Select "File" "New" "Project"
2. Select "Maven", set the JDK version, and select the template of the maven project

Insert picture description here

3. Set the project name and work location

Insert picture description here

4. Check the Maven environment

Insert picture description here

5. Wait for the project to be created and download the resources

Insert picture description here

6. After creation, the directory structure is as follows

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_51808107/article/details/112724482