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?

121603 次浏览

您需要配置 war 插件:

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

更多信息 给你

You can use the following in the web module that produces the war:

<build>
<finalName>bird</finalName>
. . .
</build>

这将导致在使用目标“ war: war”时创建一个名为 bird.war 的文件。

如果使用 maven 项目,可以按照下面的步骤修改.war 文件名。

打开 maven 项目的 pom.xml 文件并转到标记 <build></build>,

  1. 在这个标签之间给出你想要的名字: <finalName></finalName>.

    例.. <finalName>krutik</finalName>

    在部署这个.war 之后,你可以通过以下方式访问网址:
    Http://localhost:8080/krutik/

  2. 如果你想用斜杠 '/'访问网址,那么你将有 然后指定名称如下:

    欢迎回来

    在部署这个.war 之后,你可以通过以下方式访问网址:
    Http://localhost:8080/krutik/maheta

查找 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>

对我有用。 ^ ^