Java Development IntelliJ Idea+tomcat+maven under Linux

Source: Internet
Author: User

Pre-Preparation: Install IntelliJ idea, download tomcat, download maven (note I use TOMCAT6, maven 3.2.1, jdk1.6.0_45, before maven with 3.5 results error, have a long time, suggest small friends with stable version)

IntelliJ Idea official website: https://www.jetbrains.com/idea/download/#section =linux (Note to download Ultimate version, otherwise the inside of the thing is not full, such as Tomcat plugin ... )

IntelliJ idea hack: http://blog.csdn.net/zhangwenwu2/article/details/54948959

Tomcat Official Download: http://tomcat.apache.org/download-60.cgi

Maven Official Download: https://archive.apache.org/dist/maven/maven-3/

Note Download the tar.gz suffix file

Run idea, my idea is installed in the/usr/idea/idea-iu-172.3317.76 directory,& refers to the background run

Create a new project

Select Maven, tick create from archetype, then next

Fill in the appropriate information

Finish, the following option enable Auto-import

Press the shortcut key ctrl+alt+shift+s, select modules, click + sign to add a Web template for the project

Modify the Web Resource directory, Deployment descriptors for me to write the content, if there is no such directories and files, it is manually entered (for example, can only be targeted to/src/main, no WebApp You're going to have to hit the back manually.

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.

Click OK

Description: A: Now artifacts has a published project (the idea is exactly the Modele) b:output root directory Describes the current project's compilation directory and adaptation services.

Determine the structure of the current project after:

Deployment of projects

Configure Tomcat

Click the + sign in the deploment panel to add artifact

Configure the server

Writing code tests

Write a servlet, if error, because no library file was introduced

Importjava.io.IOException; Public classHellocontrollerextendsJavax.servlet.http.HttpServlet {protected voidDoPost (javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)throwsjavax.servlet.ServletException, IOException {doPost (request,response); }    protected voidDoget (javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)throwsjavax.servlet.ServletException, IOException {request.setcharacterencoding ("UTF-8"); String name= (String) request.getparameter ("name"); Request.setattribute ("Name", name);        SYSTEM.OUT.PRINTLN (name); Request.getrequestdispatcher ("Index.jsp"). Forward (Request,response); }}

Shift+ctrl+alt+s,modules Click on your own project Testmaven, click on the + sign in dependencies to select the second Add Tomcat library file by

Xml

<?xml version= "1.0" encoding= "UTF-8"? ><web-app xmlns= "Http://xmlns.jcp.org/xml/ns/javaee"         xmlns: xsi= "http://www.w3.org/2001/XMLSchema-instance"         xsi:schemalocation= "Http://xmlns.jcp.org/xml /ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd "         version=" 3.1 ">    <servlet >        <servlet-name>HelloController</servlet-name>        <servlet-class> hellocontroller</servlet-class>    </servlet>    <servlet-mapping>        < servlet-name>hellocontroller</servlet-name>        <url-pattern>/Hello</url-pattern>    </servlet-mapping></web-app>

index.jsp

  Created by IntelliJ.  User:zyh  17-7-19 time   : PM  8: This template use File | Settings | File Templates. --%><%@ page contenttype= "Text/html;charset=utf-8" language= "java"%>   Your name is: ${name}</body></ Html>

Project Structure diagram

Running Tomcat

Project I have also uploaded to GitHub, the mailbox to the friend can look at

https://github.com/Demo233/testmaven/

Java Development IntelliJ Idea+tomcat+maven under Linux

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.