Create java web project with IntelliJ IDEA 14 and Maven

http://mark.leanote.com/post/%E4%BD%BF%E7%94%A8IntelliJ-IDEA-14%E5%92%8CMaven%E5%88%9B%E5%BB%BAjava-web%E9%A1%B9%E7%9B%AE

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_HOMEthe environment variable, and then add the variable to PATH.

Note that  there must be JAVA_HOMEan environment variable, otherwise maven will prompt an error.

config

config

config

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.

config

Open CMD, enter mvn --version, and see the following prompt, indicating that the installation is successful.

config

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.

IntelliJ

new

Create a new maven project, create from archetype, select maven-archetype-webapp

maven

Next, fill in GroupId, ArtifactId and Version

maven

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. .

maven

Next, fill in the project name and module name.

maven

Click Finish.

The directory structure of the project is as follows:

tree

set up

Configure the JDK and language level of the project

config

Create a new java folder under the main folder and set it as the source code folder.

config

Add external dependency jar package for module.

config

Adding tomcat dependencies is to satisfy servletand jspdependencies, and tomcat as a servletcontainer improves the API of servletand .jsp

config

config

Add jar package dependencies.

config

Set the artifact.

config

Set up tomcat.

config

config

config

start tomca

tomcat

access

web

over!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325004610&siteId=291194637