How to use IntelliJ idea 14 to create a MAVEN3-based Java Web Project

Source: Internet
Author: User
Tags tomcat server

In conjunction with a number of other bloggers ' articles, this article describes the steps to create a MAVEN3-based Java Web Project using IntelliJ idea 14. It also introduces the possible errors and solutions.

Environment Introduction:

    • System: OS X Yosemite (10.10.5)
    • Ide:intellij Idea 14.1.4
    • Java:oracle Java 1.8.0_51
    • maven:3.3.3

To create a step:

  1. Creating the project: Create New project-> Setup SDK, select Maven, create from archetype, Maven-archetype-webapp
  2. Fill in GroupID, Artifactid, version and other information, GroupID is generally flipped domain name, Artifactid for the project ID, here I use the project name
  3. Set up maven.
    Note Here I use the MAVEN3 that the machine has installed. If you have not set the Java version used by idea startup, using an external MAVEN3 may cause an error in MacOS, see Error 1. It is recommended to use the built-in Maven3.
  4. Set the project name, project location and other information, click Finish to complete the project creation
  5. Once the project is created, you will need to wait for Maven to download the required templates and plugins to see the BACKGROUPD task run in the lower right corner of IDEA14. When you are done, you can see the project's current dependency information in MAVEN projects. The war package has also been created automatically in Project Structure->artifacts. (Note that the war package was created automatically, if not created see Error 1 or wait for MAVEN to complete the project's settings)
  6. Add Servlet-api dependency. Open the Pom.xml under the project root to add code under the Dependencies tab
    <Dependency>  <groupId>Javax.servlet</groupId>  <Artifactid>Javax.servlet-api</Artifactid>  <version>3.1.0</version></Dependency>

    Right-click Pom.xml, maven-and reimport wait for download resources. Upon completion

  7. Set up the Java source folder. Just create the project Src folder under the only WebApp folder, there is no source folder so we want to create manually. Create the folder Java under Src/main. Open Project Structure, Modules Select the Java folder that we just created in the list of items and click the Source tab. Sure you can
  8. Set up the Tomcat server. Run, Edit configurations +->tomcat Server->configure
    After setting the relevant parameters, we select the deploment tag to set up the deployed war package. Click + Add a War pack. Note Select the war package with the exploded typeface.

    After adding success, set the root path of our Access project and determine. Server Setup Complete
  9. Select Application Servers Click Start Server. Project Deployment Complete

The error that was resolved:

  1. Unable to import Maven Project:see logs for details.
    Error description: When creating the project, select External Maven3. Event log appears with error message unable to import MAVEN Project:see logs for details. Also, MAVEN cannot set the project correctly, and no information is displayed in MAVEN projects on the right. As shown

    Error reason: The external Apache Maven3 need to work with Java JDK version 1.7 or later to function properly. However, the IDEA14 under the MacOS system relies on JDK1.6 to start. This makes the two incompatible. By default, there should be JDK1.6 and a later JDK on the machine. You can view your configuration in/library/java/javavirtualmachines

    Error Resolution: Enter/applications/intellij idea 14.app/contents use a text editor or default Xcode to open Info.plist, find the following code to modify and save
    < Key > Jvmversion</key><string>1.6*,1.7+</  string>
    Switch
    < Key > Jvmversion</key><string>1.7+</ string >
    At this point, the JDK used by idea is the JDK of version 1.7 and above.
  2. Error:java:Compilation failed:internal Java Compiler Error
    Error description: An issue could not be compiled when changing the language level of the current project compilation. My configuration is that the default language level for the 5.0 JDK is 1.8. So I want the locale to be 8.0
    Error reason: There is a bytecode attribute in the idea settings compiler environment that is inconsistent with the language level property of the current project.

    Bug fix: preferences-> Java Compiler settings bytecode and Target bytecode version are consistent with the language level of the project.


    Please leave a message if you have any questions

How to use IntelliJ idea 14 to create a MAVEN3-based Java Web Project

Related Article

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.