转-Spring-Boot入门三-Springbootstarter-Maven-Template

5次阅读

共计 1123 个字符,预计需要花费 3 分钟才能阅读完成。

原文参见:Spring Boot 入门(三) – Spring-boot-starter Maven Template

近来,软件依赖库的数量呈指数级增长,这些依赖库又引入了其它依赖项,依赖治理自身也成了一项非常复杂的工作,往往一个大型项目须要大量的技术专家能力很好实现依赖治理。如果想要在我的项目中应用一些风行的库,引入 String boot starter 模板能够带来很多便当,能帮忙咱们保障我的项目中应用了正确的依赖项,减小了依赖治理的复杂性。

Spring Boot 带有 50 多种不同的启动器模块 (starter template),集成了多种不同的风行框架,例如:关系型或 NoSQL 数据库连贯、Web 服务、社交网络集成、monitoring(监控) 库、日志记录、模板渲染(template rendering)。而且,有越来越多的新集成库引入 Spring Boot,反对的集成库的列表也始终在减少。

starter template 如何工作?

Spring Boot starter 是一种 maven 模板,蕴含启动特定性能所需的所有依赖项的汇合。每个 starter 都有一个非凡的文件(pom.xml),蕴含 Spring 提供的依赖项列表。

这些依赖项能够在启动程序模块的 pom.xml 文件内找到。例如 spring-boot-starter-data-jpa starter 的 POM 文件能够从 github 上找到。

从这个 pom 文件能够看到其所引入的依赖性,所以我的项目构建中引入 spring-boot-starter-data-jpa 将同时引入 spring-orm、hibernate-entity-manager 和 spring-data-jpa。这些库为编写 JPA / DAO 代码提供所需的根本撑持。

译注:spring-boot-starter-data-jpa 2.2.x 之前应用 maven 进行 build 治理,所以对应配置文件是这个 pom.xml。从 2.3.x 开始转而应用 gradle,对应的配置文件是 builde.gradle。

当我的项目须要增加新性能的时候,倡议查看现有的 Spring Boot starter template,看看是否能够间接应用现成的 starter。Spring Boot 社区始终在继续一直地增加新的 starter template,所反对的性能范畴也始终在增长,有志之士也能够为 Spring Boot 新反对的 starter template 做出奉献。

风行的 tempate 及其依赖

下表列出了一些常常应用的 Spring Starter 及其依赖关系,仅供参考:

译注:最新的 starter 依赖请参见 github starters 各 module 下的依赖配置文件(build.gradle)。

正文完
 0