【每日阅读】2020年7月9日-springboot dependencies

索引

链接

https://github.com/spring-projects/spring-boot/tree/2.2.x/spring-boot-project/spring-boot-dependencies

简评

进入这个网页可以看到,这个项目内部只有一个pom文件(忽略xslt那个东西,那不是代码),没有任何Java代码,点进pom文件可以看到里面声明了特别多的组件的version,然后在dependencyManagement标签下面使用了那些version,这里说一下dependencyManagement是什么。dependencyManagement是maven的一个标签,用于控制依赖。例如在springboot dependencies项目的dependencyManagement标签内内声明了如下内容

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot</artifactId>
    <version>${revision}</version>
</dependency>

我们再继承springboot dependencies后,只需要如下声明依赖即可

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

即省略版本号,这样可以做到版本的上下统一。

再更进一步看我们自己的springboot项目的父项目spring-boot-starter-parent,这个项目的父项目就是springboot dependencies!

所以我们引入spring-boot-starter-parent项目的目的之一就是获得支持完善的第三方组件的版本号!spring-boot-starter-parent是不提供依赖关系的,而是管理了依赖很多组件的版本。下图来源于昨天的文章

【每日阅读】2020年7月9日-springboot dependencies

原创文章,作者:geekgao,如若转载,请注明出处:https://www.geekgao.cn/archives/2036

(0)
geekgaogeekgao博主
上一篇 2020年7月8日
下一篇 2020年7月11日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

GitHub
分享本页
返回顶部

Warning: error_log(/usr/local/lighthouse/softwares/wordpress/wp-content/plugins/spider-analyser/#log/log-2921.txt): failed to open stream: No such file or directory in /usr/local/lighthouse/softwares/wordpress/wp-content/plugins/spider-analyser/spider.class.php on line 2900