buildscript {
// springboot的版本
ext {
springBootVersion = ‘1.3.0.RELEASE’
}
repositories {
// maven的远程仓库
maven { url “http://repo.spring.io/milestone” }
mavenCentral()
}
// 依赖springboot插件
dependencies {
classpath(“org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}”)
}
}
// 安装springboot插件
apply plugin: ‘java’
apply plugin: ‘eclipse’
apply plugin: ‘idea’
apply plugin: ‘spring-boot’
// 生成jar包时的名字baseName+version
jar {
// 取项目名
baseName = project.name
version = ‘0.0.1-SNAPSHOT’
}
// 指定编译编译.java文件的jdk版本
sourceCompatibility = 1.8
// 确保class文件与targetCompatibility指定版本,或者更新的java虚拟机兼容
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
// 加载起步依赖
compile(“org.springframework.boot:spring-boot-starter-actuator”)
compile(“org.springframework.boot:spring-boot-starter-web”)
compile(“org.springframework.boot:spring-boot-starter-data-jpa”)
compile(“org.springframework.boot:spring-boot-starter-thymeleaf”)
compile(“com.h2database:h2”)
// 单元测试用的jar包
testCompile(“org.springframework.boot:spring-boot-starter-test”)
}