Gradle configurations


Gradle官網上說明:每個依賴項都有不同的作用范圍,如果想要配置可以使用configurations選項配置.
圖1.Configurations聲明的依賴項用於特定目的
圖1.Configurations聲明的依賴項用於特定目的

1|1使用groovy語言是配置gradle全局排除依賴:
configurations.all* { exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' }
 
configurations { all*.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' }
1|2使用kotlin語言配置gradle全局排除依賴:
configurations.all { exclude ( "org.springframework.boot","spring-boot-starter-logging") }

 

        SpringBoot包含了一套額外的工具集,可以讓開發的過程更加愉快。spring-boot-devtools模塊可以在任何工程中被添加,以支持一些額外的開發時特性。在構建時添加模塊的依賴,這樣項目就支持了開發者工具集,Maven和Gradle的示例如下:

Maven:

<dependencies>
  <dependency>
    <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-devtools</artifactId>
  <optional>true</optional>
  </dependency>
</dependencies>

Gradle:

configurations {
  developmentOnly
  runtimeClasspath {
  extendsFrom  developmentOnly
}
}
 
dependencies {
  developmentOnly("org.springframework.boot:spring-boot-devtools")
}

注意:

        運行一個完全打包的程序時會自動禁用開發者工具,如果你得程序通過java -jar或者通過一個特殊的類加載器啟動,則會被認為是一個“生產”程序(會禁用開發者工具集)。如果這個對你不適用(你是通過容器啟動的程序),可以考慮排除開發者工具或者設置程序的配置-Dspring.devtools.restart.enabled=false

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM