I'm using springboot 2.6.14
in one of my project.
I can read simple strings from application.yml
by using @Value
notation.
But when I convert them to List or Map, I get error
Below works
// In applicaiton.yml --
a:
b:
c: abcd
// In a java class with @Component
@Value("${a.b.c}")
String abc;
Below fails
with error Could not resolve placeholder 'a.b.c' in value "${a.b.c}"
// In applicaiton.yml --
a:
b:
c:
- abcd
- efgh
// In a java class with @Component
@Value("${a.b.c}")
List<String> abcs;
What I tried
- I tried using SPEL expression
@Value("#{${a.b.c}}")
, but same exception. - I explicitly imported
org.yaml.snakeyaml
dependency in the project, thought It might support. but same exception. - I am not allowed to upgrade the springboot version in the project.
Any other solution ?