【发布时间】:2023-04-11 06:25:01
【问题描述】:
我将 spring-boot-devtools 与我的 SpringBoot 应用程序 (2.2.8) 一起使用,以在我的存储库之外存储秘密。这适用于正在运行的应用程序,但集成测试因Unexpected exception during bean creation; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'secret.key' in value "${secret.key}" 而失败。
SecretController.kt
@RestController
class SecretController(
@Value("\${secret.key}") private val secret: String
) {
@GetMapping("/secret")
fun secret(): String {
return secret
}
}
.spring-boot-devtools.properties
secret.key: secret-asdf
在较旧的应用程序(SpringBoot 2.1)中,这可以正常工作。我知道他们changed the path with SpringBoot 2.2,但kept the old path as backwards compatibility - 我都试过了,但都没有成功。我也升级到 2.3.1,但这也无济于事。
关于如何使用 SpringBoot >= 2.2 读取集成测试中的属性有什么想法吗?
【问题讨论】:
-
似乎是 spring boot 中的一个错误... spring boot 2.1 对我来说很好。
标签: spring-boot integration-testing devtools