Deploying to tomcat using maven
This is a note to capture the process I am currently using to build and deploy a basic web application to tomcat for development.
- Create simple web app using archetype.
mvn archetype:create ... -DarchetypeArtifactId=maven-archetype-webapp
- Add server to ~/.m2/settings.xml
<servers> <server> <id>local-tomcat</id> <username>username</username> <password>password</password> </server> </servers>
- Add server to toplevel pom.xml
<build> ... <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.0-beta-1</version> <configuration> <server>local-tomcat</server> </configuration> </plugin> </plugins> </build>
- compile, test, deploy, and subsequently redeploy
$ mvn compile $ mvn test $ mvn tomcat:deploy $ mvn tomcat:redeploy
Of course what I would dearly love to know is how you configure a server url in the settings.xml file. The documentation I can find (http://mojo.codehaus.org/tomcat-maven-plugin/configuration.html) describes how to use a custom url, and how to configure authentication information. What it doesn't do is explain how you can do both at the same time, and all my attempts have resulted in XML validation errors when trying to run maven --- if I figure it out I'll update this post.