乐闻世界logo
搜索文章和话题

How to rename the war file for the project in Maven?

1个答案

1

In Maven, you can rename the generated WAR file by modifying the project's pom.xml file. Specifically, this is done by setting the <finalName> element within the <build> section.

Here is a simple example:

Assume your project name is 'SampleApp'. By default, Maven generates a WAR file named 'SampleApp-1.0.war' (assuming the version is 1.0). If you want to rename the generated WAR file to 'MyApplication.war', configure it in the pom.xml as follows:

xml
<project> ... <build> <finalName>MyApplication</finalName> ... </build> ... </project>

Here, the <finalName> tag directly specifies the WAR file name after packaging. When you run mvn package or mvn install, Maven generates the MyApplication.war file based on this setting, rather than using the default project name and version number.

This method is simple and intuitive, allowing you to easily control the WAR file name to meet your deployment requirements or naming conventions.

2024年8月15日 18:30 回复

你的答案