如何在IntelliJ"out"窗口中生成build-info.properties. Spring Boot项目的调试/运行目录? [英] How do I generate build-info.properties in the IntelliJ "out" directory on debug/run for a Spring Boot project?
问题描述
在我的build.gradle中,我添加了spring的构建信息:
In my build.gradle, I have added spring build info:
springBoot {
mainClass = "${springBootMainClass}"
buildInfo() {
additionalProperties = [
name: "${appName}",
version: "${version}-${buildNumber}",
time: buildTime()
]
}
}
def buildTime() {
final dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ")
dateFormat.timeZone = TimeZone.getTimeZone('GMT')
dateFormat.format(new Date())
}
当我从命令行运行时,这会将/META-INF/build-info.properties
文件正确地添加到/build/resources/main
中,以便"/info"
端点以JSON显示构建信息.
When I run from the command line, this correctly adds the /META-INF/build-info.properties
file into /build/resources/main
so that the "/info"
endpoint shows the build information in JSON.
当我从IntelliJ的运行/调试按钮运行时,IntelliJ不会不使用/build
目录,而是使用/out
目录,并且也不会运行gradle任务,因此
When I run from IntelliJ's run/debug button, IntelliJ does not use the /build
directory but instead uses the /out
directory and also does not run that gradle task, so the /info
endpoint has empty JSON.
如何使它生成该文件并将其放在/out
目录中?
How can I make it generate that file and put it in the /out
directory?
推荐答案
启用设置(首选项)"中的将IDE生成/运行操作委托给Gradle 选项|构建,执行,部署|生成工具|摇篮| 赛跑者标签.
Enable Delegate IDE build/run actions to Gradle option in Settings (Preferences) | Build, Execution, Deployment | Build Tools | Gradle | Runner tab.
这篇关于如何在IntelliJ"out"窗口中生成build-info.properties. Spring Boot项目的调试/运行目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!