build.gradle
{buildscript EXT { // definition of a variable, predetermined springboot unified version springBootVersion = ' 2.0.5.RELEASE ' springCloudVersion = ' Finchley.SR1 ' } Repositories { Maven {URL ' http://maven.aliyun.com/nexus/ Content / Groups / public / ' } jcenter () mavenCentral () } Dependencies { // used to package CLASSPATH ( " org.springframework.boot: Spring-Boot-Gradle-plugin: springBootVersion $ {} " ) } } allprojects { Group ' com.home ' Version = ' 0.0.1-the SNAPSHOT ' Apply plugin: ' Java ' sourceCompatibility = 1.8 Repositories { Maven {URL ' http://maven.aliyun.com/nexus/content/groups/public/ ' } mavenCentral () } // specify the encoding formats tasks.withType (JavaCompile) { options.encoding = " UTF-. 8 " } } // set the current configuration of the module project subprojects { Apply plugin: 'java' apply plugin: 'idea' //spring boot 插件 apply plugin: 'org.springframework.boot' //A Gradle plugin that provides Maven-like dependency management functionality apply plugin: 'io.spring.dependency-management' dependencies { compile ('org.springframework.boot:spring-boot-starter-web') compile group: 'com.alibaba', name: 'fastjson', version: '1.2.60' testCompile('org.springframework.boot:spring-boot-starter-test') } dependencyManagement { imports { //spring bom helps us to declare dependencies without specifying version numbers. mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" } } jar { manifest.attributes provider: 'gradle' } }
2、settings.gradle
rootProject.name = 'gradleTest' include 'api'