0

我想在注释字段中使用配置值,字段不是字符串。例如我有:

@Document(indexName = "#{@transactionIndexName}", shards = 1, 
refreshInterval = "2s", versionType = VersionType.EXTERNAL)

所以在indexName我使用spring spel,但shards是短类型值,那么我如何使用yml文件中的设置?

4

1 回答 1

0

您应该能够在 Spel 表达式中将shards值从 a转换String为 a ,如下所示:short

#{T(java.lang.Short).parseShort(${transaction.shards})}

...假设您的财产transaction.shards当然是。

我目前无法对此进行测试,但我相信这应该可行。

于 2020-03-07T15:24:13.590 回答