背景
最近在研究搭建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构建项目
项目结构
build.gradle
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打包
总结
到此这篇关于idea使用gradle构建springboot项目工程的文章就介绍到这了,更多相关idea构建springboot项目工程内容请搜索移动技术网以前的文章或继续浏览下面的相关文章希望大家以后多多支持移动技术网!
如对本文有疑问, 点击进行留言回复!!
SpringBoot实现本地存储文件上传及提供HTTP访问服务的方法
Java实现AES/CBC/PKCS7Padding加解密的方法
SpringBoot整合Spring Security的详细教程
IDEA 非常重要的一些设置项(一连串的问题差点让我重新用回 Eclipse)
详解Springboot2.3集成Spring security 框架(原生集成)
网友评论