Maven是一个项目管理工具,是基于项目对象模型的概念运作的。Maven的项目都有一个pom.xml文件用来管理项目的依赖以及编译等功能。
下面详细介绍一下各个配置元素的功能
-
dependencies元素 ,这个元素包含了多个需要的项目依赖 例如: org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test 2.1.5.RELEASE mysql mysql-connector-java
-
dependency元素 内部通过groupId、artifactId以及version这三个坐标确定唯一的依赖。 groupId : 组织的唯一标识 artifactId : 项目的唯一标识 verson : 项目的版本
-
变量定义 可定义变量在dependency中的引用 例如: <web.version>1.8</web.version> org.springframework.boot spring-boot-starter-web ${web.version}
-
编译插件 引入编译插件 org.springframework.boot spring-boot-maven-plugin true
-
Maven的运作方式 Maven会自动根据dependency中的依赖配置,直接通过互联网在Maven中心库下载相关依赖包到.m2的目录下,.m2目录下是你本地Maven库。