pom包

第一部分为项目的描述信息:

<groupId>com.neo</groupId>
<artifactId>hello</artifactId>
<version>2.0.5.RELEASE</version>
<packaging>jar</packaging>
<name>hello</name>
<description>Demo project for Spring Boot</description>



  • groupId,项目的包路径;
  • artifactId,项目名称;
  • version,项目版本号;
  • packaging,一般有两个值:jar、war,表示使用 Maven 打包时构建成 Jar 包还是 War 包;
  • name,项目名称;
  • description,项目描述。


第二部分为项目的依赖配置信息:

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.0.5.RELEASE</version>
  <relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
  </dependency>
</dependencies>

  • parent,标签内配置 Spring Boot 父级版本 spring-boot-starter-parent,Maven 支持项目的父子结构,引入父级后会默认继承父级的配置;
  • dependencies,标签内配置项目所需要的依赖包,Spring Boot 体系内的依赖组件不需要填写具体版本号,spring-boot-starter-parent 维护了体系内所有依赖包的版本信息。
  • <scope>test</scope>,表示依赖的组件仅仅参与测试相关的工作,包括测试代码的编译和执行,不会被打包包含进去;
  • spring-boot-starter-test 是 Spring Boot 提供项目测试的工具包,内置了多种测试工具,方便我们在项目中做单元测试、集成测试。

第三部分为构建时需要的公共变量:

<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  <java.version>1.8</java.version>
</properties>
第四部分为构建配置:

<build>
  <plugins>
    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
  </plugins>
</build>
        使用 Maven 构建 Spring Boot 项目必须依赖于 spring-boot-maven-plugin 组件,spring-boot-maven-plugin 能够以 Maven 的方式为应用提供 Spring Boot 的支持,即为 Spring Boot 应用提供了执行 Maven 操作的可能。spring-boot-maven-plugin 能够将 Spring Boot 应用打包为可执行的 jar 或 war 文件,然后以简单的方式运行 Spring Boot 应用。




标签: spring boot pom
2021.3.9   /   热度:1006   /   分类: java

发表评论:

©地球仪的BLOG  |  Powered by Emlog