user124441
user124441

Reputation: 11

Packaging using Maven

I have a Java web application deployed using Tomcat. I want to package the Tomcat ROOT into .WAR file using Maven. Can someone guide me through the process? Thank you

Upvotes: 1

Views: 57

Answers (1)

Marco Mendão
Marco Mendão

Reputation: 329

Create a pom.xml file in the ROOT directory with the following code.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>package</groupId>
    <artifactId>artifactid</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>project</name>
    <packaging>war</packaging>
    <build>
        <plugins>
            <plugin>            
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-war-plugin</artifactId>
              <configuration>
                <webXml>WEB-INF/web.xml</webXml>        
              </configuration>
            </plugin>
        </plugins>
    </build>

</project>

Then execute the following command in the command line mvn:clean install.

The war file will be generated to the target directory.

Upvotes: 1

Related Questions