java maven POM 中 artifactId 和 name 的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38594036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 03:33:43  来源:igfitidea点击:

difference of artifactId and name in maven POM

javamavenpom.xml

提问by javako

I am new to maven and I'm confused about the difference between the artifactIdand name.

我是 maven 的新手,我对artifactId和之间的区别感到困惑name

What I know is that artifactIdis the name of the artifact you are creating. I know that artifactIdtogether with the groupIdis use to uniquely identifies an artifact. So what is <name>purpose in POM. like the pom below I got from a site there is an artifactIdand at the same time a <name>.

我所知道的是,这artifactId是您正在创建的工件的名称。我知道artifactIdgroupIdis一起用于唯一标识工件。那么<name>POM 中的目的是什么?就像我从一个网站得到的下面的 pom 一样,有artifactId一个<name>.

<groupId>org.sonatype.mavenbook.multi</groupId>
<artifactId>simple-parent</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<name>Multi Chapter Simple Parent Project</name>

回答by OneCricketeer

You are correct that the artifactIdhelps identify the project.

您是正确的,这artifactId有助于识别项目。

The nameis simply a human-readable "friendly" name. It is not required for a basic setup.

name只是一个人类可读的“友好”名称。基本设置不需要它。

From the Maven documentation,

Maven 文档中

artifactId: The artifactId is generally the name that the project is known by. Although the groupId is important, people within the group will rarely mention the groupId in discussion ... It, along with the groupId, create a key that separates this project from every other project in the world (at least, it should :) ). Along with the groupId, the artifactId fully defines the artifact's living quarters within the repository.

artifactId: artifactId 通常是项目的名称。尽管 groupId 很重要,但组内的人很少会在讨论中提及 groupId ......它与 groupId 一起创建了一个将这个项目与世界上所有其他项目分开的密钥(至少,它应该:)) . 与 groupId 一起,artifactId 完全定义了工件在存储库中的生活区。

回答by tchambers

The groupId, artifactIdand versionform a composite unique identifier (or coordinate) for this project. Each of these values has a fairly rigid naming convention that allows well organized groups, artifacts and versions.

groupIdartifactIdversion形成复合唯一标识符(或坐标)这个项目。这些值中的每一个都有一个相当严格的命名约定,允许组织良好的组、工件和版本。

The nameis simply a readable name for the project and does not need to be unique or comply to the same conventions (so it can contain spaces and other characters).

Thename只是项目的可读名称,不需要唯一或符合相同的约定(因此它可以包含空格和其他字符)。