How eclipse deploys the project to Tomcat

Source: Internet
Author: User
Tags tomcat server

Original: HTTP://HI.BAIDU.COM/ULQEFTXYNYBIVWQ/ITEM/1B791838603A6DC31B9696BB

This article is reproduced, but unfortunately the original text has been deleted, many pictures have been hung, the following pictures are my own screenshot, a lot of local pictures may be inconsistent with the text description.


Java EE projects, commonly used tools such as Myeclipse,eclipse,netbeans, I prefer to use Eclipse, because compared to myeclipse volume, response speed, and enough to meet demand, I like the concise programming style. MyEclipse adds a lot of plug-ins, especially when you can automatically deploy your project to a Tomcat server, copy an existing project, right-click on the project, select Properties, and modify the Web project settings to the new project name. For example, if you modify Login1 to Login2,deploy, you automatically generate login2 this project folder under Tomcat WebApps, and in Eclipse, you can create a new project that, when run, can be in the workspace. Metadata\. Plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps automatically generate Login1, but if you copy this login1 directly, renamed LOGIN2, click Run will prompt to find this file, Because the project is not created, it is not deployed under the workspace. Metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps, So it's best to automatically deploy the project to Tomcat's WebApps directory, and here are two common ways to do this:

Prerequisite: The environment constructs

Jdk1.6.0+tomcat6.0+eclipse Java IDE Helios 3.6.1 (3.6.2 card machine, recommended 3.6.1)

Installation path:

C:\Java\Jdk1.6.0

C:\Java\Jre1.6.0

C:\Tomcat 6.0

C:\JavaWork my eclipse's Workbench Workbench

E:\Eclipse\Eclipse.exe Eclipse Directory

Download the full package of Struts2.1.6, copy Commons-fileupload-1.2.1.jar, Struts2-core-2.1.6.jar, and several jar packs to build the STRUTS2 project

The first is to package the project into *. War files, such as I in Eclipse, first created the project Login1, and then copied Login1 and renamed to Login2, add or modify the login2 of the class file, in order to test whether the implementation of a function, on the LOGIN2 project, select "Export", Exported as a war file, for example, named Login2. War, and then copy this login2. War file to C:\Tomcat 6.0\webapps, stop the Tomcat service, restart the Tomcat service, Login2.war will automatically extract a folder login2, and then open http://127.0.0.1:8080/ Login2/index.jsp can be accessed to test whether a function is possible. The disadvantage of this approach is that if you need to modify the source code, you must repackage the modified war file and copy it to C:\Tomcat 6.0\ WebApps and cover the original Login2.war, if you need to modify many times, you need to cover many times, a lot of meaningless work, preferably in eclipse every change in the source code, restart Tomcat service can load new code test, how to implement, see the second method.

The second goal to achieve is to have Eclipse automatically deploy the project under the C:\Tomcat 6.0\webapps of Tomcat, rather than under the workspace. Metadata\.plugins\org.eclipse.wst.server.core \tmp1\wtpwebapps, can be implemented, the method is very simple.

Create a new dynamic Web Project, named Zb4, under WebContent, create a new file login.jsp, write snippets of code, like my

<%@ page language= "java" contenttype= "text/html; charset=gb18030 "
pageencoding= "GB18030"%>
<form action = "" method= "POST" >
User name: <input type= "text" name= "username" >
Password: <input type= "text" name= "password" >
<input type= "Submit" value= "Landing" >
</form>

See figure I


Click on the Green Run button above, according to figure two


Style, click Next, and then click Finish, see Figure Three


Servers, you have added a Tomcat v6.0 Server, right-click on it, select Open, open, see Figure Four


The Server locations is grayed out and cannot be modified, as shown in Figure five


The key is to change it, so how can it be modified. To remove the items that are deployed in the first place, see figure Six


Stop the Tomcat service and remove ZB4 this item and open it again, see figure Seven


The Server locations status remains dimmed and cannot be modified to start the Tomcat service, as shown in Figure eight


After starting, open again, see figure Nine

Click Open.

You can modify the configuration of the server locations.

Configuration 3 places:

1, choose "Use Tomcat Installation", the default is "use Workspace metadata", see Figure 10;


2, check "use Tomcat insallation", the following line, the Server path automatically modified to C:\Tomcat 6.0 (Tomcat installation path), this is C:\Tomcat 6.0 can be;

3, Deploy Path needs to be modified to "WebApps", the default is "Wtpwebapps".



Click on the top right corner, close, off. Pop-up dialog box, select Yes, save settings.

At this point, the setup is complete, you can copy an item later, simply zb4 the project, right-click, select Properties, and then choose Web Project settings to modify the project name to automatically deploy to Tomcat's WebApps directory. See Figure 12.

In fact, the key of the second part is to modify the storage area of the project. To start Tomcat in Eclipse first, then follow the steps in the following diagram:

Then change the server locations to use Tomcat installation and redeploy the project OK.

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.