Install Maven
Download and install
Go to the maven official website to download the latest version.
Unzip to the installation directory.
configure
Right-click the computer icon on the desktop, Properties -> Advanced System Settings -> Environment Variables, add M2_HOME
the environment variable, and then add the variable to PATH
.
Note that there must be JAVA_HOME
an environment variable, otherwise maven will prompt an error.
If you want to modify the location of maven's local warehouse, you can set it in the settings.xml configuration file in the conf directory under the maven installation directory.
Open CMD, enter mvn --version
, and see the following prompt, indicating that the installation is successful.
Configure IntelliJ
In the IntelliJ settings, you can set the maven installation directory, the location of the settings.xml file, and the location of the local repository.
new
Create a new maven project, create from archetype, select maven-archetype-webapp
Next, fill in GroupId, ArtifactId and Version
Next, here add a parameter to Properties archetypeCatalog=internal
. Without this parameter, it will be very slow when maven generates the skeleton, and sometimes it will be directly stuck.
Explanation from the Internet:
archetypeCatalog represents the archetype metadata used by the plugin. If this parameter is not added, the default is remote, local, which is the central warehouse archetype metadata. Because the central warehouse has too many archetypes, it is very slow. Specify internal to indicate that only internal metadata is used. .
Next, fill in the project name and module name.
Click Finish.
The directory structure of the project is as follows:
set up
Configure the JDK and language level of the project
Create a new java folder under the main folder and set it as the source code folder.
Add external dependency jar package for module.
Adding tomcat dependencies is to satisfy servlet
and jsp
dependencies, and tomcat as a servlet
container improves the API of servlet
and .jsp
Add jar package dependencies.
Set the artifact.
Set up tomcat.
start tomca
access
over!