Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 555
l15a Avatar asked Dec 15 '08 20:12

l15a


People also ask

Where is WAR file in Maven project?

Now, once we execute the mvn install command, the WAR file will be generated inside the target folder. Using the mvn:war:exploded command, we can generate the exploded WAR as a directory inside the target directory.

Where do I put WAR file in Tomcat?

Perhaps the simplest way to deploy a WAR file to Tomcat is to copy the file to Tomcat's webapps directory. Copy and paste WAR files into Tomcat's webapps directory to deploy them. Tomcat monitors this webapps directory for changes, and if it finds a new file there, it will attempt to deploy it.


1 Answers

<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.

like image 169
koszu28 Avatar answered Sep 26 '22 06:09

koszu28