java - 占位符 Spring Boot 中的映射
问题描述
在必须使用注入占位符的情况下,如何将默认映射类型值传递给配置类:
foo:
bar:
mappedVariable: ${INJECTIBLE_MAP:{desired:'mapHere'}}
我不断收到此错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'foo.bar.mappedVariable' to java.util.Map<java.lang.String, java.lang.String>:
Reason: No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.lang.String, java.lang.String>]
Action:
Update your application's configuration
Process finished with exit code 0
我也试过引用值结果似乎是一样的:
foo:
bar:
mappedVariable: ${INJECTIBLE_MAP:${foo.bar.initalValues}}
initialValues:
...
将配置类中的变量名更改为 initialValues 效果很好,但我需要有注入的可能性。