[Java] JavaWeb study notes (4) - three ways for IDEA to create Maven Web projects

The first way: using a skeleton

Create steps:

1. Open File—>Project Structure—>New Maven Module

insert image description here

2. Set your own Maven path, click Finish, and idea will automatically configure and download the corresponding plug-ins

insert image description here

3. After the download is complete, the creation of the Maven Web project is basically completed

insert image description here

In the pom.xml file, there will be dependencies and downloaded plug-ins automatically configured by IDEA

insert image description here

We found that the packaging method is a war package, not a jar package. The default configuration of IDEA is a jar package, indicating that the Maven Web project we configured has been completed. Open the Facets corresponding to the Project Structure, and the Web project has been created.

insert image description here
Module directory structure

This is to find that the project is incomplete, without the Java folder and the resources resource folder, let's create it now.

insert image description here
Creation means that IDEA automatically prompts us for the folder to be created, click Create, and the Maven Web project is created.

insert image description here

The second way: without using a skeleton

1. Open File—>Project Structure—>New Module (do not check here)—>Create directly

insert image description here

At this time, the Maven project is created, but it is not a Web project, we need to manually change it to a Web project

2. Open the pom.xml configuration file, add this line of code, and change the packaging method from jar package to war package

<packaging>war</packaging>

insert image description here

3. Open Project Structure—> find Facets, click the + sign to create a new Web project

insert image description here

IDEA will automatically create the web directory and web.xml configuration file for us. In the project, rename the web webapp and move it to the main folder.

insert image description here
If the versions are inconsistent, the system does not automatically configure the webapp directory

insert image description here

It will become popular automatically, just double-click the directory to create it, and add the web.xml configuration file to complete the creation

The third way: use the JBLJavaToWeb plug-in

1. Open File—>Settings—>Plugins option—>Search JBLJavaToWeb plug-in to download and install

insert image description here
2. Right-click on the module selection option as shown in the figure below

insert image description here
insert image description here
click settings

insert image description here
After filling in the setting plug-in, the corresponding web directory and configuration file are automatically configured, and the Maven web project is created

Guess you like

Origin blog.csdn.net/weixin_43848614/article/details/129097579