jar名称中的版本 [英] Version in jar name
问题描述
当我将mvn项目导入Intellij时,它生成的jar文件不包含版本。但是mvn生成的jar有 name-version.jar
格式。所以我最终得到两个jar文件,一个是版本,另一个是没有版本。我当然可以在Intellij设置中更改模块名称以包含版本。但每当我更改pom文件时,这将被重置。
When I import mvn project into Intellij the jar file it generates doesn't include version. But mvn generated jar has name-version.jar
format. So I end up with two jar files one with version and another without one. I can of course, change module name in Intellij settings to include version. But that will be reset whenever I change pom file.
也许其他人有更好的主意?
Maybe somebody else had a better idea?
推荐答案
Maven在磁盘上生成的jar名称由 /控制project / build / finalName
所以,如果您编辑 pom.xml
看起来像
The jar name that Maven generates on disk is controlled by /project/build/finalName
so if you edit your pom.xml
to look like
<project>
...
<build>
...
<finalName>${artifactId}</finalName>
...
</build>
...
</project>
然后Maven将生成没有版本的jar文件。
and then Maven will be generating the jar file without the version.
finalName
仅控制名称磁盘上的文件。将该文件传输到本地存储库缓存或远程存储库后,它将重命名以匹配存储库布局(即 $ {artifactId} - $ {version}。$ {type}
或 $ {artifactId} - $ {version} - $ {classifier}。$ {type}
用于带分类器的工件)。您无法更改存储库使用的格式。
finalName
only controls the name of the file on disk. Once that file is transferred into the local repository cache or a remote repository it will be renamed to match the repository layout (i.e. ${artifactId}-${version}.${type}
or ${artifactId}-${version}-${classifier}.${type}
for artifacts with a classifier). You cannot change the format used by the repository.
我添加上述注释,因为在了解时,每个人似乎都想做的第一件事finalName
参数是try并更改存储库中的名称。
I add the above note because the first thing everyone seems to want to do upon learning about the finalName
parameter is try and change the name in the repository.
这篇关于jar名称中的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!