SpringBoot中pom.xml文件的学习

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.sang</groupId>
    <artifactId>chapter01-2</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>chapter01-2</name>
    <description>使用IntelliJ IDEA创建Spring Boot项目</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>2.0.3.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

不同标签含义的学习

这些标签是用于描述和管理项目依赖和构建配置的 Maven POM(Project Object Model)文件中常见的元素。下面是它们的区别:

  1. <dependencies><dependency>

    • <dependencies> 元素是包含多个 <dependency> 元素的容器。它用于列出项目所依赖的外部库、框架或模块。
    • <dependency> 元素用于定义一个单独的依赖项,指定其坐标(groupId、artifactId 和 version),以及其他属性,例如作用域(scope)和传递性(transitivity)等。
  2. <dependencyManagement>

    • <dependencyManagement> 元素用于集中管理依赖项的版本信息,以确保项目中的所有模块使用相同的依赖版本。它通常位于 POM 文件的顶层,其中列出的依赖项会被子模块继承。
    • <dependencyManagement> 中声明的依赖项不会直接添加到项目中,而是供其他模块引用时进行版本匹配和管理。
  3. <build><plugins><plugin>

    • <build> 元素用于定义 Maven 构建的各种配置,例如源代码目录、资源目录、插件配置等。它是一个容器元素,可以包含多个子元素,如 <plugins><resources><testResources> 等。
    • <plugins> 元素是 <build> 元素下的子元素,用于列出构建过程中使用的插件。每个 <plugin> 元素定义一个特定的插件,并配置其行为、目标、执行阶段等。
    • <plugin> 元素是 <plugins> 元素下的子元素,用于定义一个特定的插件及其相关配置,包括插件的坐标(groupId、artifactId 和 version)、目标(goals)、配置参数等。

总结:

  • <dependencies><dependency> 用于列出项目的依赖项。
  • <dependencyManagement> 用于集中管理依赖项的版本信息。
  • <build> 是用于定义 Maven 构建配置的容器元素。
  • <plugins><plugin> 用于定义和配置构建过程中使用的插件。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

王摇摆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值