buildscript { //buildscript代碼塊中腳本優先執行 //ext用於定義動態屬性 ext { springBootVersion = '2.0.0.M2.RELEASE' // 自定義 Thymeleaf 和 Thymeleaf Layout Dialect 的版本 ext['thymeleaf.version'] = '3.0.6.RELEASE' ext['thymeleaf-layout-dialect.version'] = '2.2.2' } //使用了maven的中央倉庫(也能夠指定其餘倉庫) repositories { mavenCentral() maven {url "https://repo.spring.io/snapshot"} maven {url "https://repo.spring.io/milestone"} maven {url "http://maven.aliyun.com/nexus/content/groups/public/"} } //依賴關係 dependencies { //classpath 聲明說明了在執行其他腳本時,calsspath可使用這些依賴項 classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } //使用插件 apply plugin: 'java' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' group = 'com.nilwu.spring.boot.blog' //指定了生成的編譯文件的版本,默認是打成了jar包 version = '0.0.1-SNAPSHOT' //指定了編譯.java 文件的JDK版本 sourceCompatibility = 1.8 //使用了maven的中央倉庫(也能夠指定其餘倉庫) repositories { mavenCentral() maven {url "https://repo.spring.io/snapshot"} maven {url "https://repo.spring.io/milestone"} maven {url "http://maven.aliyun.com/nexus/content/groups/public/"} } //依賴關係 dependencies { compile('org.springframework.boot:spring-boot-starter-web') testCompile('org.springframework.boot:spring-boot-starter-test') compile('org.springframework.boot:spring-boot-starter-thymeleaf') }