I have a dependency jar which has values configured in yaml as below:
app:
settings:
value1 : true
And the java code is
public class LoadConfig {
@Value("${app.settings.value1}")
private Boolean value1;
}
While deploying the spring boot app, in runtime, the dependency jar values are not parsed and below issue occurred.
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}**].
The issue is instead of value, path(app.settings.value1) is getting converted to Boolean and the error is thrown.
maven project structure is
MyJar --> app.jar
|-> dependency.jar
import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; – Arunkumar Dec 24 '19 at 07:02