Create a maven project with IDEA (foolish steps)


(First time using maven, you need to connect to the Internet)

1. IDEA configures local maven

使用idea创建maven工程之前需要将本地的maven配置到idea环境中,配置方法如下:

1.1 Configure local maven

  1. Step 1: Open default settings (effective for future new projects):
    Insert image description here
    2. Step 2: Configure the paths of maven_home and settings.xml:
    Insert image description here

1.2 Configure maven parameters

使用idea创建maven项目后,默认会去网络中下载一些配置资源。需要设置参数archetypeCatalog。
设置方法如下:将-DarchetypeCatalog=internal 设置到Maven--Runner--VM Options中。

Insert image description here

参数:-DarchetypeCatalog=internal

2. Create a maven java project

使用maven创建的项目可分为3种类型:普通java项目,web项目和maven的父工程。 
这三种项目对象的打包方式分别是:jar,war和pom。

2.1 Creation steps

Step 1: File–New–Project
Insert image description here
Step 2: Select maven and then next step:
Insert image description here
Step 3: Fill in the coordinate information of the project:
Insert image description here
Step 4: Specify the project name and path: idea will remove the - in the project name, we Just add it.
Insert image description here

2.2 Introduction to java project directory

Insert image description here

2.3 Testing

Write main program code
Insert image description here
Write test code
Insert image description here
Test results
Insert image description here

3. Create a web project

3.1 Creation steps

Step 1: Create a normal java project.
Follow the steps to create a maven java project.

Step 2: Configure the packaging method.
The packaging method of the web project is war, and open the pom file of the maven project. Add a label under the coordinate information of the project and set the packaging method.

Insert image description here
Step 3: Configure the webapp directory and web.xml

Open the Project Structure view

Insert image description here
Insert image description here
The effect is as follows
Insert image description here
Step 4: Creation is completed

设置完成之后,main目录下会创建webapp-WEB-INF-web.xml。

Insert image description here

3.2 Publish web projects

Step 1: Edit Configurations
Step 2: Add local tomcat.
Follow the sequence of numbers and icons in the figure below: + --> Tomcat Server --> Local

Insert image description here
Step 3: Configure tomcat
Insert image description here
Insert image description here
Step 4: Start testing

在webapp目录下新建一个index.html文件,文件内容如下:

Insert image description here
After starting tomcat, visit index.html. If index.html can be accessed correctly. Description project creation OK.
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_43811057/article/details/108237008