1、基本配置
- modelVersion:pom模型版本,maven2和3只能为4.0.0
- groupId:组ID,用于定位当前项目位置
- artifactId:在组中的唯一ID,用于定位当前项目位置
- version:当前项目版本
- packaging:项目打包方式,有以下值:pom, jar, maven-plugin, ejb, war, ear, rar, par,在J2EE项目中通常是war,在spring项目中通常是jar
<modelVersion>4.0.0</modelVersion> <groupId>com</groupId> <artifactId>springboot</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging>
2、父项目依赖配置
- groupId:组ID,用于定位父项目位置
- artifactId:在组中的唯一ID,用于定位父项目位置
- relativePath:Maven首先在当前项目的找父项目的pom,然后在文件系统的这个位置(relativePath),然后在本地仓库,再在远程仓库找,该标签可有可无
- version:父项目版本
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <relativePath></relativePath> <version>1.5.8.RELEASE</version> </parent>
3、常量配置
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>
上面这个常量可以在pom文件的任意地方通过${project.build.sourceEncoding}来引用
4、相关依赖配置
- scope:指定classpath,可以是compile,provided,runtime,test,system,默认是compile
- compile:指示这个dependency会传播到项目中
- provided:
- runtime:
- test:指示这个dependency在一般程序运行是无效的,但是在test的compilation和execution是有效的
- system:
<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies>
添加了依赖之后,会下载相应的依赖的jar到本地仓库中