vks
vks

Reputation: 7071

Deploying a project using Maven

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.

Upvotes: 1

Views: 168

Answers (4)

stratwine
stratwine

Reputation: 3701

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.

Upvotes: 2

user481572
user481572

Reputation:

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

Upvotes: 1

Ryan Stewart
Ryan Stewart

Reputation: 128829

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

Upvotes: 1

Ramon
Ramon

Reputation: 8424

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.

Upvotes: 1

Related Questions