How to package a webapp as a deployable war?
-
20-08-2019 - |
Question
I'm new to Maven but I'm hooked on what it offers. How do I take a webapp and have Maven package the webapp as a deployable WAR? Additionally, can I set up Maven to automatically version the builds?
Solution
Here is an example from the getting started guide:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-webapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>my-webapp</finalName>
</build>
</project>
OTHER TIPS
Change to the project's directory and type:
mvn clean package
target/my-webapp.war is built
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow