Maven: How to rename the war file for the project?
I have a project bird
with the following components in pom.xml
<groupId>com.myorg</groupId>
<artifactId>bird</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>bird</name>
<modules>
<module>persistence</module>
<module>business</module>
<module>service</module>
<module>web</module>
</modules>
and the web module pom.xml
<parent>
<artifactId>bird</artifactId>
<groupId>com.myorg</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>web</artifactId>
<packaging>war</packaging>
The web module creates a war file named web-1.0-SNAPSHOT.war
How can I configure maven to build it as bird.war
?
You can use the following in the web module that produces the war:
<build>
<finalName>bird</finalName>
. . .
</build>
This leads to a file called bird.war to be created when goal "war:war" is used.
You need to configure the war plugin:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>bird.war</warName>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
More info here
Lookup pom.xml > project tag > build tag.
I would like solution below.
<artifactId>bird</artifactId>
<name>bird</name>
<build>
...
<finalName>${project.artifactId}</finalName>
OR
<finalName>${project.name}</finalName>
...
</build>
Worked for me. ^^
You can follow the below step to modify the .war file name if you are using maven project.
Open pom.xml file of your maven project and go to the tag <build></build>
,
-
In that give your desired name between this tag :
<finalName></finalName>
.ex. :
<finalName>krutik</finalName>
After deploying this .war you will be able to access url with:
http://localhost:8080/krutik/ -
If you want to access the url with slash '/' then you will have to specify then name as below:
e.x. :
<finalName>krutik#maheta</finalName>
After deploying this .war you will be able to access url with:
http://localhost:8080/krutik/maheta