IDEA使用Gradle构建SpringBoot项目工程的详细教程
作者:智慧zhuhuix 时间:2022-08-31 16:28:26
背景
最近在研究搭建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 {
mavenCentral()
}
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打包
来源:https://blog.csdn.net/jpgzhu/article/details/107562739
标签:IDEA,Gradle,SpringBoot,项目工程
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
SpringBoot使用自动配置xxxAutoConfiguration
2022-11-20 09:05:56
java获取文件的inode标识符的方法
2021-06-19 15:10:49
Unity Shader实现描边OutLine效果
2022-01-13 03:11:13
![](https://img.aspxhome.com/file/2023/0/76380_0s.gif)
JetBrains IntelliJ IDEA 配置优化技巧
2022-06-19 08:31:38
![](https://img.aspxhome.com/file/2023/7/64067_0s.png)
Unity3D实现人物转向与移动
2022-10-28 08:42:13
10分钟带你理解Java中的弱引用
2023-02-09 10:35:55
基于java集合中的一些易混淆的知识点(详解)
2023-08-29 03:06:26
Java中final修饰的方法是否可以被重写示例详解
2022-02-25 13:35:40
Java实现顺序表和链表结构
2023-11-13 09:35:43
![](https://img.aspxhome.com/file/2023/2/62832_0s.jpg)
详细解读Java Spring AOP
2022-10-09 11:06:06
![](https://img.aspxhome.com/file/2023/5/83455_0s.jpg)
Toolbar制作菜单条过程详解
2022-11-29 04:13:59
Java SpringCache+Redis缓存数据详解
2023-11-29 01:01:05
![](https://img.aspxhome.com/file/2023/1/60131_0s.jpg)
springBoot之如何获取接口请求数据和返回数据实现日志
2023-11-23 10:43:58
关于eclipse中运行tomcat提示端口被占用的4种解决
2022-04-15 10:56:12
C#使用linq查询大数据集的方法
2023-05-24 16:52:17
Spring基于注解的缓存声明深入探究
2023-01-20 13:26:06
springboot+springmvc+mybatis项目整合
2023-07-16 03:13:57
![](https://img.aspxhome.com/file/2023/1/61251_0s.png)
如何解决@NotBlank不生效的问题
2022-04-01 13:41:08
![](https://img.aspxhome.com/file/2023/0/82980_0s.png)
在springboot中对kafka进行读写的示例代码
2023-11-26 00:48:02
![](https://img.aspxhome.com/file/2023/7/60457_0s.png)
完美解决gson将Integer默认转换成Double的问题
2022-06-06 00:53:36