Create a simple maven-based SPRINGMVC project in IntelliJ idea

Source: Internet
Author: User

Tool is IntelliJ idea 2017.2-month version

First step: Create New project, find the MAVEN option on the left, and then step (the project structure that the webapp generated is not very good, such as no Main/java folder, no Test/java folder, And the folders are not set to sources, resources, and so on, and web. XML is actually 2.3 version; I wonder if you have any other recommendations):

Next after the new window is filled in groupid and artifactid,groupid generally refers to the group/team name, such as Com.alibaba, if an individual can fill in an English name, usually lowercase English.

Artifactid is generally the name of this project. Then keep next and finish. (You can actually set some other parameters, such as Maven without the idea default, write the simplest here first)

After a few seconds, idea created the structure of the project (created by Maven archetype):

Here's the idea of creating this archetype Maven project where the comparison pits are first removed (and perhaps later without these pits after the upgrade):

① Click on the File-project Structure above, then click Modules, then click on the middle part of the project name, and then find the right side of the language level to change its value to 8 (or its own JDK version, where the default is 5), click OK to save, Process

Then click on File-settings on the idea, search for Java Compiler, change the two value to 1.8,

OK after the first pit is changed (personally think 1.5 is too low, and the JRE is backwards compatible, at least 1.6 by default)

② the generated Web. XML, which was originally version 2.3:

<!  ><Web-app>  < display-name  >archetype Created Web application</display-name></ Web-app >

Can be changed (note that the 2.3 version of the El expression in the JSP is not supported, that is, ${msg} will not be parsed by Tomcat):

<?XML version= "1.0" encoding= "UTF-8"?><Web-appXmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xmlns= "Http://xmlns.jcp.org/xml/ns/javaee"xsi:schemalocation= "Http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"ID= "webapp_id"version= "3.1">  <Display-name>Archetype Created Web Application</Display-name></Web-app>

The second pit is done.

The next step is to refine the MAVEN project structure and related configuration

The first step is to change the pom.xml into the jar package of the dependency, after the change to pay attention to the Pom.xml right--maven-reimport (I do not do so, Maven will not help me to relate the package, if there is a better way to tell)

Second step (important), open Project Structure-modules-sources,

(Here, I missed a step, in the middle of the ideamaventest above click on the green + number, then select the Web column, then apply; If you do not, you will not be able to right-click within the webapp of the project structure to find the new-jsp option)

Note that at this time there is no Test/java folder in SRC (for testing, recommended), and there is no Java folder under Main, first the SRC right-click New folder is named Test, and then the new test folder right-click New folders named Java, Then right-click on this Java folder to select Tests.

Then to the main right-click New folder named Java, the Java folder right-click on the sources, and then the resources right under main selected as resources, click OK to save.

Next, under the Web-inf directory, the new folder is named View, and the project structure is:

The next step is to create a package such as a controller, service, and so on in the Java folder in main, create a JSP file in view, Create the Springmvc.xml file in the resources file (note that the files/folders in Java and resources at this time are peer, and they will be output to the Classes folder (Classpath))

The rest of the steps I'm not going to talk about, this is for those who have created Eclipse's Dynamic Web project and Maven project, if you haven't created it, it's recommended to create several eclipse projects (Eclipse is still a must-see)

Specific can refer to my: http://www.cnblogs.com/silentdoer/p/7134332.html

Integration with me: http://www.cnblogs.com/silentdoer/articles/7133685.html

Create a simple maven-based SPRINGMVC project in IntelliJ idea

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.