使用 Spring Boot 和 Gradle 时,依赖项闭包中有一些注释,如“tag::jetty[]”和“end::jetty[]”。鉴于它们的语法,我假设它们是由 spring boot gradle 插件之类的东西解析的。这些有什么作用?他们是否需要让 Spring Boot 执行器和嵌入式码头工作?
sample 来自 docs下面(请参阅依赖项关闭):
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.10.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-spring-boot'
version = '0.1.0'
}
repositories {
mavenCentral()
}
dependencies {
// tag::jetty[]
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
compile("org.springframework.boot:spring-boot-starter-jetty")
// end::jetty[]
// tag::actuator[]
compile("org.springframework.boot:spring-boot-starter-actuator")
// end::actuator[]
testCompile("junit:junit")
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
最佳答案
如Gradle Getting Started guide on spring.io底部所述:
Note: There are many start/end comments embedded here. This makes it possible to extract bits of the build file into this guide for the detailed explanations above. You don’t need them in your production build file.
所以不,你不需要标签。它们仅用于在代码更改时自动更新指南的位。
关于gradle - spring boot gradle文件中的 "tag::..."语法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27924759/