Maven构建 —— groupId、artifactId、version概念

前言

博主在学习Spring Maven构建的时候,经常会引入以下结构代码:

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-indexer</artifactId>
        <version>5.2.6.RELEASE</version>
        <optional>true</optional>
    </dependency>
</dependencies>

最后它们整合成一个标识唯一资源的地址:

org.springframework:spring-context-indexer-5.2.6.RELEASE

那么这里的 groupId、artifactId 、version是什么意思呢?

Maven构建

groupId

官方定义: the unique identifier of the organization or group that created the project

简单理解:

  • 是项目组织唯一的标识符,实际对应JAVA的包的结构,是main目录里java的目录结构。
  • 定义了项目属于哪个组。

举个例子:如果有个公司叫做单片机菜鸟,正在做一个叫做spring的项目,那么 groupId 我们可以定义为:

com.dpjcn.spring

artifactId

官方定义:unique base name of the primary artifact being generated by this project

简单理解:

  • 是项目的唯一的标识符
  • 定义了当前maven项目在组中唯一的ID

举个例子:接着上面的例子,spring项目下又分为多个module。

spring-mvc
spring-boot
spring-ioc

version

  • 指定了myapp项目的当前版本,SNAPSHOT意为快照,说明该项目还处于开发中,是不稳定的版本。

所以,一个完整的maven项目整体路径:
groupId:artifactId - version

猜你喜欢

转载自blog.csdn.net/dpjcn1990/article/details/106467617