简体   繁体   中英

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.

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.

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM