1. 程式人生 > 實用技巧 >使用Gradle建立springcloud專案

使用Gradle建立springcloud專案

第一步新建專案,這都不用說了,有手就行

第二步選中SpringInitalizr Project SDK 是專案使用的jdk版本 直接引入就可以了

Group

選你需要的依賴,無所謂,你也可以什麼都不選,到時候再maven庫找你需要的就行了


這就不再是想maven的pom檔案了,這個是要在build.gradle中了
plugins {
id 'org.springframework.boot' version '2.3.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}

version = '0.0.1-SNAPSHOT'

subprojects {
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
sourceCompatibility = '11'
targetCompatibility = '11'
repositories {
maven{
url="http://maven.aliyun.com/nexus/content/repositories/central/"
}
}

ext {
set('springCloudAlibabaVersion', "2.2.1.RELEASE")
set('springCloudVersion', "Hoxton.SR4")
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter'
implementation 'org.springframework.cloud:spring-cloud-starter-security'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-oauth2', version: '2.2.4.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
compile group: 'cn.hutool', name: 'hutool-all', version: '5.4.1'
compile group: 'com.alibaba', name: 'fastjson', version: '1.2.73'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
}

dependencyManagement {
imports {
mavenBom "com.alibaba.cloud:spring-cloud-alibaba-dependencies:${springCloudAlibabaVersion}"
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

test {
useJUnitPlatform()
}

}
其他應該沒了,我缺了什麼,留言告訴我