Maven Coordinates Maven 的坐标

Maven Coordinates 坐标

groupId、artifactId、version 是所有需要的字段,groupId 和 version 可以从一个 parent 文件中继承,这个时候它们可以不被明确定义。这三个字段扮演的就像地址和时间戳,它们在 Maven 项目中就像坐标系统一样,在一个仓库里面指定了一个特定的位置。

groupId:这个其实是组织的信息,组织的唯一标识,例如 org.apache.maven,不过这里不一定要一定使用点这个符号,也不必要一定要和项目的包结构对应上,当然,最好是对应上,这样其实在 maven 仓库里面就可以呈现出很好的目录结构。

groupId: This is generally unique amongst an organization or a project. For example, all core Maven artifacts do (well, should) live under the groupId org.apache.maven. Group ID’s do not necessarily use the dot notation, for example, the junit project. Note that the dot-notated groupId does not have to correspond to the package structure that the project contains. It is, however, a good practice to follow. When stored within a repository, the group acts much like the Java packaging structure does in an operating system. The dots are replaced by OS specific directory separators (such as ‘/‘ in Unix) which becomes a relative directory structure from the base repository. In the example given, the org.codehaus.mojo group lives within the directory $M2_REPO/org/codehaus/mojo.

artifactId:制品 Id,这个是在 group 下面一级的概念,是在组织内部用来区分的信息,理解上感觉就是组织下面的项目。

version: 版本信息,在制品信息内部来区分各个版本的信息。

This is the last piece of the naming puzzle. groupId:artifactId denotes a single project but they cannot delineate which incarnation of that project we are talking about.