创建 Spring Boot 项目时是否可以生成应用程序属性?

Is there a way to generate application properties when creating a Spring Boot project?

我打算 运行 我们自己的 Spring Initializr 实例。有没有办法在选择某个选项时将一组应用程序属性写入(到application.yml),最好是在一组预定义配置文件的每个单独部分中?我研究了在 Initializr 中自定义项目生成过程并创建自定义启动器。我遇到了 auto-configuration for starters, but that seems to be about what configuration to default to when this has not been provided by properties, whereas I am after generating the properties. I've also come across an 的自定义 Spring Initializr 实例生成文件,但我需要它 modify application.yml 而不破坏任何其他修改可能已经做到了。

Spring Initializr(start.spring.io背后的库)没有yaml支持,不允许你在项目生成时自动写入这样的文件。

尽管如此,您添加该功能还是很容易的。它的工作方式是通过贡献者调整的模型 + 将模型转换为目标输出的作者。与此类比的是 MavenBuildMavenBuildWriter 生成 Maven 的 pom.xml.

自动配置确实与 code/configuration 生成完全无关,因此无需查看那里。