1. 程式人生 > 實用技巧 >Spring Boot的使用:Gradle

Spring Boot的使用:Gradle

[

13.3. Gradle

Gradle使用者可以直接在它們的dependencies節點處匯入”starters“。跟Maven不同的是,這裡不用匯入"super parent",也就不能共享配置。

apply plugin: 'java'

repositories {
    maven { url "http://repo.spring.io/snapshot" }
    maven { url "http://repo.spring.io/milestone" }
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web:1.4.1.BUILD-SNAPSHOT")
}

跟maven類似,spring boot也有gradle外掛spring-boot-gradle-plugin,它能夠提供任務用於建立可執行jar,或從原始碼(source)執行專案。它也提供依賴管理的能力,該功能允許你省略Spring Boot管理的任何依賴的version版本號:

buildscript {
    repositories {
        maven { url "http://repo.spring.io/snapshot" }
        maven { url "http://repo.spring.io/milestone" }
    }

    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.BUILD-SNAPSHOT")
    }
}

apply plugin: 'java'
apply plugin: 'spring-boot'

repositories {
    maven { url "http://repo.spring.io/snapshot" }
    maven { url "http://repo.spring.io/milestone" }
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    testCompile("org.springframework.boot:spring-boot-starter-test")
}
]
  •   本文標題:Spring Boot的使用:Gradle - Break易站轉載請保留頁面地址:https://www.breakyizhan.com/springboot/3080.html