Spring 中使用 Kotlin 函数式风格的 Yaml 类型安全配置

Yaml type-safe configuration in Spring using Kotlin Functional Style

我正在尝试按照演示 https://github.com/sdeleuze/spring-kotlin-functional 使用 Spring Boot 2 中发布的无注释新方法创建新的 Spring Boot 应用程序。我的问题是如何在不使用注释的情况下继续使用 Yaml 文件来配置我的应用程序?我猜这可能是 Beans 配置中的某些内容,但我没有找到关于该主题的任何文档。谢谢

beans dsl 有一个 env 属性,您可以使用它来检索在 yaml、属性文件或命令行中定义的任何 environment 属性参数:

fun beans() = beans {
    bean<SomeBeanThatNeedsConfig> { 
      SomeBeanThatNeedsConfig(env.getProperty("config.value"))
    }
}