build.gradle
buildscript { ext { //定义一个变量,统一规定springboot的版本 springBootVersion = '2.0.5.RELEASE' springCloudVersion = 'Finchley.SR1' } repositories { maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } jcenter() mavenCentral() } dependencies {//用来打包 classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } allprojects { group 'com.home' version = '0.0.1-SNAPSHOT' apply plugin: 'java' sourceCompatibility = 1.8 repositories { maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } mavenCentral() } //指定编码格式 tasks.withType(JavaCompile) { options.encoding = "UTF-8" } } //设定当前模块项目中的配置 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'