• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

IDEA使用Gradle构建SpringBoot项目工程的详细教程

springboot 搞代码 4年前 (2022-01-05) 32次浏览 已收录 0个评论

这篇文章主要介绍了IDEA使用Gradle构建SpringBoot项目工程的教程详解,本文通过图文并茂的形式给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

背景

最近在研究搭建spring源码调试环境时,接触到到gradle项目构建工具。由于之前习惯于maven项目的构建,故通过此文记录相关gradle的项目构建知识。

Gradle

Gradle是一个构建工具,用于管理项目依赖和构建项目工程。Gradle抛弃了Maven的基于XML的繁琐配置,采用特定语言Groovy的配置,大大简化了构建代码的行数。

项目结构

Plugin Sample

 pluginManagement { repositories { gradlePluginPortal() maven { url 'https://repo.spring.io/plugins-release' } } } plugins { id "com.gradle.enterprise" version "3.2" id "io.spring.gradle-enterprise-conventions" version "0.0.2" } include "spring-aop" include "spring-aspects" include "spring-beans" include "spring-context" include "spring-context-indexer" include "spring-context-support" include "spring-core" include "kotlin-coroutines" project(':kotlin-coroutines').projectDir = file('spring-core/kotlin-coroutines') include "spring-expression"

IDEA使用Gradle构建SpringBoot项目工程

新建SpringBoot项目

使用Gradle构建项目

项目结构

  • src结构和maven结构一致;gradle文件夹 存放gradle wrapper相关文件;build.gradle相当于maven里面的pom.xml,setting.gradle用于多模块的配置。

build.gradle

  • plugins:插件配置;
  • sourceCompatibility:jdk版本号
  • repositories:仓库配置,mavenCentral()代表中央仓库;
  • dependencies:依赖的坐标集合
 plugins { id 'org.springframework.boot' version '2.3.1.RELEASE' id 'io.spring.dependency-management' version '1.0.9.RELEASE' id 'java' } group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '1.8' repositories { m<mark style="color:transparent">来源gaodaimacom搞#代%码网</mark>avenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } } test { useJUnitPlatform() }

添加依赖

项目依赖的格式为 作用范围修饰符 ( ‘groupId:artifactId:version’ )

 dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa compile ('org.springframework.boot: spring-boot-starter-data-jpa: 2.3.1 ') }

gradle打包

总结

到此这篇关于IDEA使用Gradle构建SpringBoot项目工程的文章就介绍到这了,更多相关IDEA构建SpringBoot项目工程内容请搜索gaodaima搞代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持gaodaima搞代码网

以上就是IDEA使用Gradle构建SpringBoot项目工程的详细教程的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:IDEA使用Gradle构建SpringBoot项目工程的详细教程

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址