Steps for deploying a MAVEN Web project to Tomcat in Eclipse __web

Source: Internet
Author: User
Tags tomcat tomcat server
People who have used eclipse know that there is a to-MC at Eclipse plug-in, you can easily debug Tom Cat project, the specific configuration will not say, look at the use of plug-in instructions to know

When using MAVEN to manage a project, there are also maven Tomcat plugins, but it is inconvenient to use for frequently modified projects. Because the MAVEN project structure differs from the project structure created by Eclipse by default, there is no class and jar under WebApp, and debugging with Tomcat Eclipse is definitely not going to work. But there's still a way of saving the nation.

The following sections are excerpted from the network

1. Modify the Tomcat Server.xml configuration file and add the following code under the host node

<context docbase= "F:\webapp" path= "/demo" reloadable= "true" ></Context>


This allows Tomcat to instantly perceive changes to the files in the F:\webapp directory and automatically redeploy them. However, our class files and configuration files are compiled under Target/classes. Don't worry, go on.



2. Go back to Eclipse, right click on the demo project, choose Java Build Path, click on the Source tab, modify the bottom default output fold er to demo/src/main/webapp/web-inf/ Classes Then select the Output folder option under Demo/src/main/java and demo/src/main/resources above and click the Edit button to select the first project's default output folder, Click OK.

Java is then compiled into the classes directory under Web-inf, which is perceived by Tomcat. However, there are also project maven dependency packages.




3. In general, once a project's dependency package stabilizes, there will not be much change. So, simply copy the maven dependency package to Web-inf/lib. The following are the specific practices:
Go to the command line and switch the current directory to the project root directory. Run command
Reference MV N Depende NC y:copy-dependencies

The dependencies of the demo project are then directed to the target/dependency and copied to the Web-inf/lib. If the dependency package is changed, it will be better to do it again.




Attention:
If you end up using MAVEN to package the project into a war, you also need to change the Java class's compilation path back, and delete the classes directory and the Lib directory under Web-inf, or you will get an error.

Gorgeous split line-----------------------reprinted end---------------------

To summarize, although the above method solves the problem of Tomcat hot deployment and debugging, but after all, slightly moved MAVEN's structure, in fact, with Jetty do server debugging can perfect match Eclipse and Maven run, there is no problem of Tomcat, only need to install the run The jetty plug-in is available. In the actual project, we can use jetty to do the development of the service, using MAVEN to fight the war package deployed on Tomcat on
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.