apply from: 'dependencyDefine.gradle' // SpringBoot buildscript { ext { springBootVersion = '2.1.3.RELEASE' } repositories { mavenLocal() // maven { url = "http://maven.aliyun.com/nexus/content/groups/public" } mavenCentral() maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } subprojects { apply plugin: 'java' apply plugin: "idea" // apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' group = 'com.qxgmat' version = '0.0.1-SNAPSHOT' sourceCompatibility = 1.8 targetCompatibility = 1.8 tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } repositories { mavenLocal() maven { url = "http://maven.aliyun.com/nexus/content/groups/public" } mavenCentral() } dependencies { compile("org.springframework.boot:spring-boot-starter") compile("org.springframework.boot:spring-boot-starter-web") compile('org.springframework.boot:spring-boot-starter-aop') compile('org.springframework.boot:spring-boot-starter-jdbc') compile('org.springframework.boot:spring-boot-starter-data-jpa') // compile("org.springframework.boot:spring-boot-starter-security") compile("org.springframework.boot:spring-boot-starter-actuator") compile('org.springframework.boot:spring-boot-starter-logging') compile('org.springframework.boot:spring-boot-starter-cache') compile('org.springframework.boot:spring-boot-starter-data-redis') compile("org.springframework.boot:spring-boot-devtools") compile('mysql:mysql-connector-java') testCompile("org.springframework.boot:spring-boot-starter-test") compile fileTree(dir:'libs',include:['*.jar']) } //自定义环境 start def env = System.getProperty("env") ?: "dev" sourceSets { main { resources { srcDirs = ["src/main/resources", "src/main/profile/$env", "src/main/java"] } } } //自定义环境 end } // 如果不使用spring boot plugin,也可以使用spring boot dependency management,只需要导入SpringBootPlugin类的BOM_COORDINATES常量 //dependencyManagement { // imports { // mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES // } //} //如果module中名称有包含api的,则加入下面的内容 configure(subprojects.findAll {it.name.contains('api')}) { apply plugin: 'war' apply plugin: 'application' springBoot { buildInfo() } // war { // manifest { // attributes("Implementation-Title": "Gradle") // } // } dependencies { // providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' providedRuntime 'org.springframework.boot:spring-boot-starter-jetty' } } project(':data') { dependencies { compile(project(":tools")) } } project(':gateway-api') { dependencies { compile(project(":tools")) compile(project(":data")) } }