This article describes how to use intellijidea 12 to create a Java Web project managed by Maven.
PDF document: Http://download.csdn.net/detail/zht666/5141235
1. Create a project, select Maven module, enter the project name, and click Next to continue.
Note that the module here refers to the project, which is equivalent to the project in myeclipse.
Click Finish.
The Maven project after creation. Double-click Pom. XML to view the content of the POM file. You can add Maven Dependencies by yourself. But I found that there is no web directory. What should I do? Later.
Right-click the project name and select Add framework support...
In the Add framework support dialog box, select Web application, version 3.0, and select create web. xml.
Click OK and you will see the following interface. The Web file is displayed in the project. Are you familiar with it? It is similar to the project structure in myeclipse.
Open the Pom. xml file and add necessary Maven dependencies. It is also called the maven coordinate. A set of jar dependent files are uniquely identified by groupid, artifactid, and version.
I addedPom. xmlThe file content is as follows:
<? XML version = "1.0" encoding = "UTF-8"?> <Project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion> 4.0.0 </modelversion> <groupid> springmvcdemo </groupid> <artifactid> springmvcdemo </artifactid> <version> 1.0-Snapshot </version> <dependencies> <dependency> <! -- JUnit 4.7 --> <groupid> JUnit </groupid> <artifactid> JUnit </artifactid> <version> 4.11 </version> <type> jar </type> <scope> test </scope> </dependency> <! -- Spring 3.2 --> <groupid> Org. springframework </groupid> <artifactid> spring-context </artifactid> <version> 3.2.1.release </version> <type> jar </type> </dependency> <groupid> log4j </groupid> <artifactid> log4j </artifactid> <version> 1.2.17 </version> <type> jar </type> </dependency> <! -- Jackson core package --> <groupid> COM. fasterxml. jackson. core </groupid> <artifactid> Jackson-core </artifactid> <version> 2.1.3 </version> </dependency> <! -- Jackson data binding package --> <groupid> COM. fasterxml. jackson. core </groupid> <artifactid> Jackson-databind </artifactid> <version> 2.1.3 </version> </dependency> <! -- Jackson annotation package --> <groupid> COM. fasterxml. jackson. core </groupid> <artifactid> Jackson-annotations </artifactid> <version> 2.1.2 </version> </dependency> </dependencies> </Project>
Add some content to the index. jsp file.
Configure the Tomcat server below. In this example, Tomcat 6 is used.
For example, select local and click Configure. In the displayed dialog box, select the tomcat installation directory.
Select Tomcat server, and then click "+" in green.
Click "+" and select local. The local Tomcat server has been configured.
A new Tomcat service is created here. Enter any name.
Click deployment, and then click "+" on the right to add artifact deployment.
Click OK to return to the main interface, click application servers to open the Server View, and click tomcat6 [local] to view the project deployment. Click the start button on the top of the page to start the Tomcat server. After the startup, the server automatically opens the browser.