How to copy .war to Tomcat's webapps directory using Maven?

l15a picture l15a · Dec 15, 2008 · Viewed 56.2k times · Source

Is there anything I can add to pom.xml that will copy the generated .war file from the target directory to my Tomcat's webapps directory?

Answer

koszu28 picture koszu28 · Feb 11, 2011
<build>
   <plugins>
     <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.1</version>
        <configuration>
           <outputDirectory><!-- Tomcat webapps location--></outputDirectory>
           <!-- Example of Tomcat webapps location :D:\tomcat\webapps\ -->
        </configuration>
      </plugin>
    </plugins>
</build>

Once you have added it to your pom.xml, you can copy the WAR file by calling mvn package or mvn war:war.