在Kotlin中使用YAML的@Value和List

97 浏览
0 Comments

在Kotlin中使用YAML的@Value和List

我试图在一个使用Kotlin的Spring Boot项目中,从一个YAML文件初始化属性列表。对于普通字符串,它可以正常工作,但是当我尝试使用以下错误初始化List时会失败:

Unexpected exception during bean creation; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'foo.bars' in value "${foo.bars}"

Kotlin代码有以下构造函数参数:

@Value("\${foo.bars}")
val foobars: List

YAML文件有以下值:

foo:
  bars:
  - test1
  - test2

我需要在列表和普通字符串之间做一些不同的事情吗?

admin 更改状态以发布 2023年5月25日
0