IntelliJ idea 15 creating a MAVEN project

Source: Internet
Author: User

Original: IntelliJ idea 15 creating a MAVEN project

Description

    • How to create a maven project: Create it manually
    • Benefits: Refer to IntelliJ idea 14 to create a MAVEN project two (this article describes the benefits of creating a MAVEN project in this way) and IDEA14 to create a Web project using MAVEN (this article describes the drawbacks of creating Maven with templates.) )
Create a new MAVEN project
    • New A project

    • Do not select any Maven templates

    • Play a GroupID, Arifactid

    • A project name. Note: Idea_project is the working interval for this project, MAVENDEMO_IDEA15 is the subdirectory where this item is stored.

    • After building the project, open, click Auto-import

    • The following structure for this project

Project deployment
    • Click

Project: No setup required (of course, click Project complier output to customize the compilation directory)

Modules: you can see that this project does not have any adaptation service components (because Maven was created manually, no Maven templates were selected)-so we need to add them.

    • Select Web (Add Web service component for this project, this is a Web project)

    • Now set the resource directory for the Web. Double-click Web Resource Directory

    • Select Scr/main Directory

    • Add WebApp at the back. Well, the Ok,web resource directory is set up.

    • Now set the directory for the Web description file

    • Set in the WebApp directory

Facts: Represents the appropriate service component for the current project. You can see that this project is already a Web project.

Aftifacts:This aftifacts describes the current project release information. Now add and select from Modeles.

Description: A: Now artifacts has a published project (the ideais exactly modele) B: TheOutput root directory Describes the current project's compilation directory and adaptation service.

Determine the structure of the current project after:

    • If necessary, add Lib package

Deploying servers

    • Add Server

    • Deployment

Note: Many children's shoes cannot be found here arifact, please refer to the configuration of modules in the deployment project. If the Web service component is not configured for the project, then there is no artifact. (The current project is not even a Web project, where is the artifact, and what is deployed?) )

    • Note the following selections:

Writing code tests
    • Create a Java class. There's a problem with inheritance HttpServlet--it's because you didn't add Tomcat dependencies to the module

    • Join Tomcat Dependency in modules

Add complete

    • Now press the shortcut key to do it.

    • Code editing

Java

 PackageCOM.WQL;Importjavax.servlet.ServletException;ImportJavax.servlet.annotation.WebServlet;ImportJavax.servlet.http.HttpServlet;Importjavax.servlet.http.HttpServletRequest;ImportJavax.servlet.http.HttpServletResponse;Importjava.io.IOException;/*** Created by Lenovo on 2016/2/25.*/@WebServlet ("/mycontroller") Public classControllerextendsHttpServlet {@Overrideprotected voidDoget (httpservletrequest req, HttpServletResponse resp)throwsservletexception, IOException {doPost (req, resp); } @Overrideprotected voidDoPost (httpservletrequest req, HttpServletResponse resp)throwsservletexception, IOException {//System.err.println ("---"); //Fix garbledReq.setcharacterencoding ("UTF-8"); String name=req.getparameter ("name"); Req.setattribute ("Name", name);        SYSTEM.OUT.PRINTLN (name); Req.getrequestdispatcher ("Index.jsp"). Forward (req, resp); }}

Html

<%--Created by IntelliJ. User:lenovoDate:  ./2/ -   Time: 0: -   toChange this template use File | Settings | File Templates.--%><%@ Page ContentType="Text/html;charset=utf-8"language="Java" %><HTML><Head>    <title>Title</title></Head><Body><formAction= "Mycontroller"Method= "POST">    <inputname= "Name">Return:${name}<inputvalue= "Submit"type= "Submit"></form></Body></HTML>

Xml

<?XML version= "1.0" encoding= "UTF-8"?><Web-appxmlns= "Http://java.sun.com/xml/ns/javaee"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"version= "3.0"><welcome-file-list>    <Welcome-file>index.jsp</Welcome-file></welcome-file-list></Web-app>
    • Remember to set the default startup browser

    • Start Project

IntelliJ idea 15 creating a MAVEN project

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.