IntelliJ idea 12 and TOMCAT7 configuration

Source: Internet
Author: User

Idea, IntelliJ ideas, is the integrated environment for Java language development, and IntelliJ is recognized as one of the best Java development tools in the industry, especially in smart Code assistants, code auto-hinting, refactoring, Java EE support, various version tools (Git, SVN, GitHub, etc.), JUnit, CVS integration, code analysis, innovative GUI design and other aspects of the function can be said to be extraordinary. Idea is the product of JetBrains, a company headquartered in Prague, the capital of the Czech Republic, where developers are based in Eastern European programmers with a rigorous reputation. Its flagship version also supports Html,css,php,mysql,python and so on. The free version only supports a few languages such as Java.

System configuration: Win7 64bit,intellij idea 12,TOMCAT7

Let's talk about the two configurations related to Tomcat:

1. Configure the default port

In the Server.xml file in the Conf directory of the Tomcat installation directory, the Port property in the following specifies the default ports:

<connector connectiontimeout= "20000" port= "8080" protocol= "http/1.1" redirectport= "8443"/>

2. Bind the URL to the Web program directory
The default root directory is Tomcat7\webapps\root, and we can specify the root directory and other directories in the Conf\server.xml file host tag, for example:

According to the above configuration, when we visit http://127.0.0.1/aaa, we use the Web program in the F:\AAA directory, the same as BBB. The root path is not changed. Three ways to set up the root directory are mentioned in http://nj-apple-tree.iteye.com/blog/1635953:

After Tomcat is installed by default, Tomcat's home directory is the Webapps/root directory, so if you want to change Tomcat's home directory, you can do the following, so the first method is: Open C:/tomcat/conf/server.xml, < Add code between host>
Back to the chase, say how to configure IntelliJ idea 12 with TOMCAT7:

1, use idea to establish a project todo_web, placed in the F:\idea_wp\todo_web directory, the index.jsp content is modified as follows.

<%--Created by IntelliJ idea. --%><%@ page contenttype= "Text/html;charset=utf-8" language= "java"%>

While Since Webapps\root was previously emptied by me, a file index.html was created in the directory, as follows:

Hello Tomcat

2. Click "File---Settings->application Servers" To add Tomcat to the right of the window and set the Tomcat home and base dir.
3. (optional) Open "File-and project Structure" to see if Project Sdk,libs,artifact is configured.

4. Open "Run, Edit Configurations" and click "+" on the left to add the server and configure it:

After "OK", click the Run button on the right side of the Mytomcat (green triangle):

Running Effects and other:

At this point, we visit http://127.0.0.1:8080/in the browser, we see "Hello Tomcat", and the access http://localhost:8080/todo/can see "Hi,todo".
We saw that the access Todo worked, but the tomcat\conf directory didn't change, like we switched off the Tomcat process that idea started. We went into Tomcat's Bin directory to run Startup.bat directly, and it was not possible to access "/todo" for the simple reason that the idea was to run Tomcat and reset the variable, and here's some of the output when it started Tomcat:

[2013-10-30 06:57:57,692] Artifact Web:war Exploded:server is not connected. Deploy is not available. Using catalina_base:   "C:\Users\letian\. Intellijidea12\system\tomcat\unnamed_todo_web "Using Catalina_home:   " D:\TOMCAT7 "Using Catalina_tmpdir:" D:\ Tomcat7\temp "Using jre_home:        " D:\java\jre_7u25_32bit "

We open the directory C:\Users\letian\. Intellijidea12\system\tomcat\unnamed_todo_web, you can see the Conf directory, the directory specified by the AppBase attribute of the host tag in the Server.xml file is changed to an absolute path (D:\TOMCAT7 \webapps), in the \catalina\localhost directory, there is a new file Todo.xml, which reads as follows:

<?xml version= "1.0" encoding= "UTF-8"? ><context path= "/todo" docbase= "F:\idea_wp\todo_web\out\artifacts\ Web_war_exploded "/>

So idea can start a tomcat on every Web project, as long as the port is different.

Go on

The above configuration started without, after a period of time found always can not deploy, did not find the reason, simply configure again,
1. Open "File-and Project Structure->artifacts" To add the Web application exploded, named Todo_web:

2. Open "Run-with Edit Configurations" and edit Mytomcat:

At this point, the run succeeds.

IntelliJ idea 12 and TOMCAT7 configuration

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.