Intellij idea creating a MAVEN Web project

Source: Internet
Author: User

1 Preface

In the project creation, IDEA provides a number of project templates, such as the Spring MVC template, which can be directly created with a MAVEN-based spring MVC demo, with all configurations set up and ready to be used for direct compilation of the deployment.

The first time you create a MAVEN Web project yourself, either create a SPRINGMVC project to modify it, create a MAVEN project (not a Web project), add a WebApp directory to add the configuration Web. xml file, and add a website moudle. Configuration properties, and so on.

In addition to the previous summary of several IntelliJ use the article, there are more or less some problems, please take this article as the subject.

The interface for creating a project after IntelliJ 13.1 has been adjusted, but the exact steps are still the same. The version used in this article is 13.1.2,

2 Creating a MAVEN Web project

New project--maven--Check the Create from archetype check WebApp


Next (figure) fill in the project GroupId Artifactid version after next appears the following interface

Add project name after next finish

The first time you use it, you may need to download archetype WebApp plug-ins Sometimes it may take a long time for the network to be bad.

After you've created it, you'll need to wait a moment to load the configuration file, as shown in

The project is now MAVEN's WebApp project.

This time the IDE has a cache that needs to be refreshed in the right MAVEN project to load the configuration in the Pom

(after adding the jar dependency in the POM, click on the Refresh button of Maven project to swipe the cache)

This time the Maven WebApp project is completely created and no more configuration is required in project structure

The following two graphs are configured by default and do not need to be modified

3 Configuration instructions for MAVEN Web projects
Configuration of artifaces in Project structure

As shown, there are two wars in Aritifaces, one is war exploded, and you need to select the war when configuring the server exploded

It is important to note that these two wars should not be added by themselves, but rather based on the configuration generated by Maven itself.

In the absence of these two wars, I created them myself, often with the consequence that the project was missing a jar package after compilation and the dependent jar was not automatically copied

In fact IntelliJ in the Mavan project configuration, are dependent on the configuration in the Pom, if the configuration in the Pom is correct, you do not need to modify the project's IDE configuration

    1. first Pom to have <packaging>war</ Packaging>, if this is configured in the POM, aritifaces there will be two war

    2. above. Li style= "padding:0px; margin:0px ">

      next Pom to have <build>     <finalName>test</finalName>  </build> This relates to the configuration in the output directory, finalname as the project directory under Target, And a war package that will create the corresponding name (such as Test.war)

Configure Src/main/java

For example, if the Java directory is missing from the Src/main directory, we can right-click to create the directory Java and then configure the sources directory in the modules.

So the Src/main/java icon becomes blue, as a Java source code area.


Thank you @ Wu Junshen, in Maven settings, you can tick this option to automatically add dependencies when modifying POM

(always thought that was automatically imported into MAVEN project)


Finally, thank you. @ Codlin finishing a very good tutorial on IntelliJ use, http://www.oschina.net/question/7728_150494

Friends you like can learn a little bit.

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.