为什么SpringBoot项目里引入其他依赖不要写版本号


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

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
  • 先观察一下上面的配置,有没有发现什么?没错,都没有版本号。好神奇呀!怎么做到的?

  答:这就是SpringBoot自动配置的强大魅力。在我们创建一个SpringBoot项目的时候,我们的项目其实都会继承spring-boot-starter-parent项目,这是SpringBoot提供的一个启动器父级工程,在这个项目里面SpringBoot对所有可能用到的组件的版本号进行了统一管理。

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
</parent>

 

你再也不用担心使用某个组件会不会产生冲突问题了。SpringBoot说:一切都有我!


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM