依赖管理,以任一个pom.xml为例,都有<parent>标签里的<artifactId>spring-boot-starter-parent</artifactId>

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <project xmlns="http://maven.apache.org/POM/4.0.0"
    3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    5. <modelVersion>4.0.0</modelVersion>
    6. <groupId>com.atguigu</groupId>
    7. <artifactId>boot-01-helloworld</artifactId>
    8. <version>1.0-SNAPSHOT</version>
    9. <packaging>jar</packaging>
    10. <parent>
    11. <groupId>org.springframework.boot</groupId>
    12. <artifactId>spring-boot-starter-parent</artifactId>
    13. <version>2.3.4.RELEASE</version>
    14. </parent>
    15. <!-- <properties>-->
    16. <!-- <mysql.version>5.1.43</mysql.version>-->
    17. <!-- </properties>-->
    18. <dependencies>
    19. <dependency>
    20. <groupId>org.springframework.boot</groupId>
    21. <artifactId>spring-boot-starter-web</artifactId>
    22. </dependency>
    23. <dependency>
    24. <groupId>org.projectlombok</groupId>
    25. <artifactId>lombok</artifactId>
    26. </dependency>
    27. <dependency>
    28. <groupId>org.springframework.boot</groupId>
    29. <artifactId>spring-boot-devtools</artifactId>
    30. <optional>true</optional>
    31. </dependency>
    32. <!-- <dependency>-->
    33. <!-- <groupId>org.springframework.boot</groupId>-->
    34. <!-- <artifactId>spring-boot-starter-batch</artifactId>-->
    35. <!-- </dependency>-->
    36. <!-- <dependency>-->
    37. <!-- <groupId>mysql</groupId>-->
    38. <!-- <artifactId>mysql-connector-java</artifactId>-->
    39. <!-- </dependency>-->
    40. </dependencies>
    41. <build>
    42. <plugins>
    43. <plugin>
    44. <groupId>org.springframework.boot</groupId>
    45. <artifactId>spring-boot-maven-plugin</artifactId>
    46. </plugin>
    47. </plugins>
    48. </build>
    49. </project>

    点进<artifactId>spring-boot-starter-parent</artifactId>

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    3. <modelVersion>4.0.0</modelVersion>
    4. <parent>
    5. <groupId>org.springframework.boot</groupId>
    6. <artifactId>spring-boot-dependencies</artifactId>
    7. <version>2.3.4.RELEASE</version>
    8. </parent>
    9. <artifactId>spring-boot-starter-parent</artifactId>
    10. <packaging>pom</packaging>
    11. <name>spring-boot-starter-parent</name>
    12. <description>Parent pom providing dependency and plugin management for applications built with Maven</description>
    13. <properties>
    14. <java.version>1.8</java.version>
    15. <resource.delimiter>@</resource.delimiter>
    16. <maven.compiler.source>${java.version}</maven.compiler.source>
    17. <maven.compiler.target>${java.version}</maven.compiler.target>
    18. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    19. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    20. </properties>
    21. </project>

    再点进<artifactId>spring-boot-dependencies</artifactId>
    spring-boot-dependencies-2.3.4.RELEASE.pom当中几乎声明了所有开发中常用的依赖的版本号,自动版本仲裁机制

    1. <properties>
    2. <activemq.version>5.15.13</activemq.version>
    3. <antlr2.version>2.7.7</antlr2.version>
    4. <appengine-sdk.version>1.9.82</appengine-sdk.version>
    5. <artemis.version>2.12.0</artemis.version>
    6. <aspectj.version>1.9.6</aspectj.version>
    7. <assertj.version>3.16.1</assertj.version>
    8. ...
    9. <mysql.version>8.0.17</mysql.version>
    10. ...
    11. </properties>

    所以以后我们开发,无需关注版本号,自动版本仲裁,引入依赖默认都可以不写版本
    那么我们引入依赖就可以不用写版本,就会默认使用底层的对应依赖版本号

    1. <dependency>
    2. <groupId>mysql</groupId>
    3. <artifactId>mysql-connector-java</artifactId>
    4. </dependency>

    也可以修改默认版本号,模仿底层的版本写法

    1. 1、查看spring-boot-dependencies里面规定当前依赖的版本用的 key。
    2. 2、在当前项目里面重写properties配置
    3. <properties>
    4. <mysql.version>5.1.43</mysql.version>
    5. </properties>
    6. <dependency>
    7. <groupId>mysql</groupId>
    8. <artifactId>mysql-connector-java</artifactId>
    9. </dependency>

    但是如果以后引入非版本仲裁的jar【还是我们说的依赖】,要写版本号