Spring Boot - 系统构建

Spring Boot - 系统构建 首页 / Spring Boot入门教程 / Spring Boot - 系统构建

在Spring Boot中,选择构建系统是一项重要任务。无涯教程建议使用MavenGradle,因为它们为依赖项管理提供了良好的支持。

依赖管理

Spring Boot团队提供了一系列依赖关系,以支持其每个发行版的Spring Boot版本,您无需在构建配置文件中提供依赖项的版本。 Spring Boot根据发行版自动配置依赖项版本。请记住,当您升级Spring Boot版本时,依赖项也会自动升级。

注意-如果要指定依赖版本,则可以在配置文件中指定它。但是,Spring Boot团队强烈建议不需要为依赖关系指定版本。

Maven依赖

对于Maven配置,应该继承Spring Boot Starter父项目来管理Spring Boot Starters的依赖项。为此,无涯教程可以简单地在 pom.xml ,如下所示。

<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>1.5.8.RELEASE</version>
</parent>

应该为Spring Boot Parent Starter依赖项指定版本号。然后,对于其他启动程序依赖项,不需要指定Spring Boot版本号。遵守下面给出的代码-

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

Gradle依赖

可以将Spring Boot Starters依赖项直接导入到 build.gradle 文件中。不需要像Maven for Gradle这样的Spring Boot start Parent依赖项。

buildscript {
   ext {
      springBootVersion='1.5.8.RELEASE'
   }
   repositories {
      mavenCentral()
   }
   dependencies {
      classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
   }
}

同样,在Gradle中,无涯教程不需要为依赖关系指定Spring Boot版本号。 Spring Boot根据版本自动配置依赖关系。

dependencies {
   compile('org.springframework.boot:spring-boot-starter-web')
}

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

技术领导力实战笔记 -〔TGO鲲鹏会〕

Go语言核心36讲 -〔郝林〕

DevOps实战笔记 -〔石雪峰〕

SRE实战手册 -〔赵成〕

Service Mesh实战 -〔马若飞〕

Django快速开发实战 -〔吕召刚〕

说透数字化转型 -〔付晓岩〕

全链路压测实战30讲 -〔高楼〕

高并发系统实战课 -〔徐长龙〕

好记忆不如烂笔头。留下您的足迹吧 :)