此版本仍在开发中,尚不被认为是稳定的。对于最新的稳定版本,请使用 Spring Boot 3.5.5spring-doc.cadn.net.cn

与执行器集成

生成构建信息

弹簧靴执行器的info端点在存在META-INF/build-info.properties文件。 一个BuildInfotask 来生成此文件。使用该任务的最简单方法是通过插件的 DSL:spring-doc.cadn.net.cn

springBoot {
	buildInfo()
}
springBoot {
	buildInfo()
}

这将配置一个BuildInfo名为bootBuildInfo并且,如果存在,则使 Java 插件的classes任务依赖于它。任务的目标目录将是META-INF在主源代码集资源的输出目录中(通常build/resources/main).spring-doc.cadn.net.cn

默认情况下,生成的构建信息派生自项目:spring-doc.cadn.net.cn

属性 默认值

build.artifactspring-doc.cadn.net.cn

的基本名称bootJarbootWar任务spring-doc.cadn.net.cn

build.groupspring-doc.cadn.net.cn

项目组spring-doc.cadn.net.cn

build.namespring-doc.cadn.net.cn

项目名称spring-doc.cadn.net.cn

build.versionspring-doc.cadn.net.cn

项目版本spring-doc.cadn.net.cn

build.timespring-doc.cadn.net.cn

项目建设时间spring-doc.cadn.net.cn

可以使用 DSL 自定义属性:spring-doc.cadn.net.cn

springBoot {
	buildInfo {
		properties {
			artifact = 'example-app'
			version = '1.2.3'
			group = 'com.example'
			name = 'Example application'
		}
	}
}
springBoot {
	buildInfo {
		properties {
			artifact.set("example-app")
			version.set("1.2.3")
			group.set("com.example")
			name.set("Example application")
		}
	}
}

要从生成的构建信息中排除任何默认属性,请将其名称添加到排除项中。例如,time属性可以按如下方式排除:spring-doc.cadn.net.cn

springBoot {
	buildInfo {
		excludes = ['time']
	}
}
springBoot {
	buildInfo {
		excludes.set(setOf("time"))
	}
}

的默认值build.time是构建项目的瞬间。这样做的副作用是任务永远不会是最新的。因此,构建将花费更长的时间,因为必须执行更多任务,包括项目的测试。另一个副作用是任务的输出总是会发生变化,因此,构建将无法真正可重复。如果您更看重构建性能或可重复性而不是build.time属性,排除time属性,如前面的示例所示。spring-doc.cadn.net.cn

还可以将其他属性添加到生成信息中:spring-doc.cadn.net.cn

springBoot {
	buildInfo {
		properties {
			additional = [
				'a': 'alpha',
				'b': 'bravo'
			]
		}
	}
}
springBoot {
	buildInfo {
		properties {
			additional.set(mapOf(
				"a" to "alpha",
				"b" to "bravo"
			))
		}
	}
}

可以使用Provider.spring-doc.cadn.net.cn