A lab aimed to develop a "typical" solution for Spring MVC/Maven web application deployment to Tomcat 7. Requirements are:
- There should be a solution to run application locally.
- There should be a solution to configure, build and deploy application to Tomcat 7 server.
How to play with it
- Running application locally using embedded Jetty:
mvn clean jetty:run-exploded. Because I have no idea how to make it work with
jetty:runwithout lots of extra stuff in
pom.xml, my solution is: first, build
warpackage and explode it, then, run exploded package with Jetty.
- Deploying application to Tomcat 7 (predefined settings):
mvn clean tomcat7:redeploy -Ptomcat-deployment
- Deploying application to Tomcat 7 (Teamcity settings):
mvn clean tomcat7:redeploy -Pteamcity. This will expect the environment to provide:
TOMCAT_SERVER- server name described in Maven's
TOMCAT_URL- URL of Tomcat's management application. Normally, something like
TOMCAT_PATH- relative path to deploy application to. Example:
ENVNAME- used only for illustrative purposes. Can be whatever desired.
ROOTURL- used only for illustrative purposes. Can be whatever desired.
Tomcat 7 should have a user with deployment permissions. This is done by making changes to
<tomcat-users> ... <user name="deployer" password="deploy123" roles="manager-script" /> ... </tomcat-users>
Deployment requires Maven to have credentials for accessing Tomcat's management service. This is done by making changes to
<settings> ... <servers> ... <server> <id>TomcatServer</id> <!-- It's, BTW, what `TOMCAT_SERVER` is --> <username>deployer</username> <password>deploy123</password> </server> ... </servers> ... </settings>