问题描述
我有一个要构建的Maven项目,而没有版本.
I have a maven project that I want to build without version.
现在,当我使用maven构建项目时,它会创建此commonjerseylib-1.0.war
,但是我需要创建此commonjerseylib.war
.
Now, when I build the project using maven, it creates this commonjerseylib-1.0.war
but I need this commonjerseylib.war
to be created.
除此之外,我从pom.xml
中删除了<version>
标记,但默认情况下Maven仍在使用war
和1.0版进行创建.
In addition to that, I remove <version>
tag from pom.xml
but still Maven is creating with war
with version 1.0 by default.
我的pom.xml
:
<modelVersion>4.0.0</modelVersion>
<groupId>commonjerseylib</groupId>
<artifactId>commonjerseylib</artifactId>
<packaging>ear</packaging>
<name>commonjerseylib</name>
<!--<version>1.0</version>-->
如何在不使用版本的情况下进行构建?
How to build it without version ?
推荐答案
您将始终需要项目的版本号,但是可以更改生成的包的名称(JAR,WAR,EAR等).通过POM中的<finalName>
元素.
You will always need a version number for a project, however it is possible to change the name of the generated package (JAR, WAR, EAR, etc.) through the <finalName>
element in the POM.
<project>
...
<build>
...
<finalName>${project.artifactId}</finalName>
...
</build>
...
</project>
或旧版本的Maven:
or in older versions of maven:
...
<finalName>${artifactId}</finalName>
...
默认情况下,finalName是${project.artifactId}-${project.version}
,但是可以将其更改为其他名称.这只会影响在target
目录中创建的包的名称;在本地存储库中并上传到远程存储库的文件名将始终具有版本号.
By default, the finalName is ${project.artifactId}-${project.version}
, but this can be changed to something else. This will only affect the name of the package created in the target
directory; the file name in the local repository and uploaded to remote repositories will always have a version number.
有关更多信息,请参见 POM参考文档.
See the POM reference documentation for more information.
这篇关于如何构建没有版本的Maven项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!