1

I have created a project in Eclipse and built it using Maven. I need to deploy my project to my Tomcat server after packaging the project. How can I do this? I have already added my Tomcat server to Eclipse.

Adrian Petrescu
  • 16,629
  • 6
  • 56
  • 82
vks
  • 6,649
  • 7
  • 36
  • 55
  • Do you use Tomcat for development? Have you considered using jetty for development? With maven all you have to do is: "mvn jetty:run" in your project root path, and you can configure it to auto-restart every time a change is made in classes, and it is really really fast, compared to tomcat – Jaime Hablutzel Sep 17 '11 at 21:42

4 Answers4

2

While developing, if you use M2E plugin, then you can still let M2E build the project and simply use Run on Server by right clicking on the project. That's the easiest.

If Run on Server is not shown on the menu, you could simply right click the project --> Enable faceted form and then check on Dynamic Web Module as in this screenshot

For maven plugin options, apart from what @Ramon pointed out, there's t7mp T7MP is useful from an integration testing point of view. You may refer to the configuration wiki page for more info.

Community
  • 1
  • 1
stratwine
  • 3,663
  • 2
  • 26
  • 32
1

Seems there is now an official maven plugin for tomcat here. I have used the old version which seems to be the more stable option.

Ramon
  • 8,202
  • 4
  • 33
  • 41
1

To deploy a web project to an Eclipse Tomcat server: http://www.eclipse.org/webtools/community/tutorials/BuildJ2EEWebApp/BuildJ2EEWebApp.html

To learn about deploying apps to a standalone Tomcat server: http://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html

Ryan Stewart
  • 126,015
  • 21
  • 180
  • 199
1

edit (or create if it doesn't exist) your $HOME/.m2/settings.xml to include the following server block, this assumes your $CATALINA_HOME/conf/tomcat-users.xml has an entry like

<user username="tomcatuser" password="tomcatpw" roles="tomcat, manager-gui"/>

<settings>
  <servers>
    <server>
      <id>tomcat</id>
      <username>tomcatuser</username>
      <password>tomcatpw</password>
    </server>
  </servers>
</settings>

Then you can deploy to tomcat with maven using

mvn tomcat:deploy

For further tomcat deployment settings for maven see

http://mojo.codehaus.org/tomcat-maven-plugin/configuration.html