Configure the Javaweb project for quick deployment to Tomcat under Eclipse

Source: Internet
Author: User

With the use of VS, Eclipse, there is a completely from the automatic to the manual block feeling ah.

Many students in the eclipse under the development of Web projects, every time to modify the code, see the effect of the right-click Project->run AS--Run on server, and then slowly open Eclipse's built-in browser, display the following interface, so that people look particularly melancholy!

On the Internet to check a lap, the other way is basically teaching you to publish the project to the WebApp directory of the Tomcat directory, although better than the default method, but http://localhost:8080/InskyScheduleCenter/ The kind of URL really makes the egg ache, good a project to be as a directory exists, if some page resource files are still used relative path way to write, that adjust the display of the page is more fire, there is a simple deployment way, like VS, choose Publish, The file is automatically copied to the specified directory, and then in the browser to hit the URL to access it, the Internet to find a lap, really did not find, I made an afternoon, finally found a method, hereby share to everyone.

Let's take a step-by-step start:

    1. Tomcat Configuration

      Open your Tomcat directory under the Conf\server.xml file, first add your own local virtual site, er, directly grab 80 port, easy to use.

      There is a service node in Server.xml, which is placed under the original service node according to copy.

< Service name= "Schedulecenter" >

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

<connector Port="18580" protocol="ajp/1.3" Redirectport="8443"/>

<engine defaulthost="www. Schedulecenter.com " name=" schedulecenter ">

<realm classname= "Org.apache.catalina.realm.LockOutRealm" >

<realm className="Org.apache.catalina.realm.UserDatabaseRealm" resourcename ="userdatabase"/>

</Realm>

appbase= "WebApps" autodeploy = "true" name= "www. Schedulecenter.com " unpackwars = "true"

<alias> www. schedulecenter.com </ALIAS>

<context docBase="E:\publish\tomcat\wtpwebapps\InskyScheduleCenter" Path = "" reloadable="true"/>

<valve classname= "Org.apache.catalina.valves.AccessLogValve" Directory= "Logs" pattern= "%h%l%u%t &quot;%r&quot; %s%b " prefix= "Localhost_access_log." suffix= ". txt" />

</Host>

</Engine>

</Service>

According to the configuration above, listen to port 80, and then configure the domain name Mapping www.ScheduleCenter.comto point the directory of this site to E:\publish\tomcat\wtpwebapps\InskyScheduleCenter. Specific Tomcat site configuration can write another article, interested students can go to check other information, here is not irrelevant to pull away.

    1. Eclipse Configuration

      First we already have a javaweb website, as for the website how to write, we also do not pay attention here.

      On the project right-->run as-a Run on server, the old way to get a tomcat server, do not say anything, note the server version of the JRE what version is selected.

Then finish, this server is ready, this is everyone familiar with the Eclipse default run site configuration.

Below, let's make some changes, and in the case of this server run, open the server panel.

Click on the bottom of the Inskyschedulecenter, right click Remove, and then on the top of the localhost (2), mail, select Open, pop Up the following dialog box:

Note that if the inskyschedulecenter is not removed at this point, or if the server is not in the start state, all options for this panel are grayed out and not operable.

Note that selecting the box shown in the Red box in the diagram indicates that the item is published in the directory you specify, and in the bottom two text boxes, fill in the Path and deployment directory of the server, and CTRL + S is saved after the operation is done.

Then right-click on the project to->run as Run on Server,ok, at which point you can see that the project has been published to the E:\publish\tomcat\wtpwebapps directory.

If you sometimes publish directory points to find missing files, you can first select clean in the server panel, and then select Publish.

Above, is the first time you need to perform the operation.

After that, we change the code in Eclipse, the status of the site will become republish, if set up automatic synchronization, it will quickly become synchronnized, if not automatically synchronized, manually right-click Publish to the code can be redeployed to our E:\ The Publish\tomcat\wtpwebapps directory.

    1. Change the Host file

      Change the Windsow host file to establish a local site map

      127.0.0.1 www.ScheduleCenter.com

    2. accessing the browser

      Turn off the Tomcat service in Eclipse and start the Tomcat service, I'm using the XAMPP

      When you run, you can access the Web site by typing the URL in the browser.

      At this point, we just need to change the code in Eclipse, just on the server in the Services panel, see that the site's status is republish, right-click Publish to deploy the updated code to the site, and then refresh the page to see the latest changes.

Configure the Javaweb project for quick deployment to Tomcat under Eclipse

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.