我有一个依赖项jar,其值在yaml中配置如下:
app:
settings:
value1 : true
Java代码为
public class LoadConfig {
@Value("${app.settings.value1}")
private Boolean value1;
}
在部署spring boot应用程序时,在运行时,未解析依赖项jar值,并且发生了以下问题。
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'LoadConfig':
Unsatisfied dependency expressed through field 'value1'; nested exception is
org.springframework.beans.TypeMismatchException:**Failed to convert value of type 'java.lang.String' to required type 'java.lang.Boolean'**; nested
exception is java.lang.IllegalArgumentException: Invalid boolean value [**${app.settings.value1}**].
问题不是值,而是将path(app.settings.value1)转换为布尔值并引发错误。
Maven项目结构为
MyJar --> app.jar
|-> dependency.jar