How do I deploy a maven web application to Tomcat?
Author: Deron Eriksson
Description: This tutorial describes how to deploy a maven web application to Tomcat using the maven tomcat plugin.
Tutorial created using:
Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1) || Tomcat 6.0.14
(Continued from page 1) Now, I'd like to create an EclipseSW external tool configuration to perform a deploy of a selected project using the tomcatSW mavenSW plugin. To do so, I first perform a "clean" phase to clean the selected project. After this I perform the "tomcat:deploy" goal to build and deploy the warW file.
The external tool configuration is shown here. I selected the "mywebapp" project in my Eclipse Navigator view and then ran the external tool that we just created. It generated the following console output: Console output from 'mvn clean tomcat:deploy'[INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'tomcat'. [INFO] ------------------------------------------------------------------------ [INFO] Building mywebapp Maven Webapp [INFO] task-segment: [clean, tomcat:deploy] [INFO] ------------------------------------------------------------------------ [INFO] [clean:clean] [INFO] Deleting directory C:\dev\workspace\mywebapp\target [INFO] Preparing tomcat:deploy [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] [INFO] Compiling 1 source file to C:\dev\workspace\mywebapp\target\classes [INFO] [resources:testResources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:testCompile] [INFO] No sources to compile [INFO] [surefire:test] [INFO] No tests to run. [INFO] [war:war] [INFO] Packaging webapp [INFO] Assembling webapp[mywebapp] in [C:\dev\workspace\mywebapp\target\mywebapp] [INFO] Processing war project [INFO] Webapp assembled in[76 msecs] [INFO] Building war: C:\dev\workspace\mywebapp\target\mywebapp.war [INFO] [tomcat:deploy] [INFO] Deploying war to http://192.168.1.7:8080/mywebapp [INFO] OK - Deployed application at context path /mywebapp [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5 seconds [INFO] Finished at: Wed Feb 06 11:10:48 PST 2008 [INFO] Final Memory: 10M/19M [INFO] ------------------------------------------------------------------------ In the Tomcat Manager, if I click the "List Applications" link, the "mywebapp" application appears at the bottom of the list. The "mywebapp" war file was successfully deployed to Tomcat using the tomcat maven plugin. Although not shown here, if I try hitting my test servletW in the "mywebapp" application running on Tomcat, it succeeds. Related Tutorials:
|