I'm trying to create a Map<Integer,List<Integer>>
variable into Java service.
I have this .yml:
my:
data:
'{
1:[1,2,3],
2:[1,2,3]
}'
And into Java code:
@Value("#{${my.data}}")
protected Map<Integer,List<Integer>> bar;
But it fails when I run the project.
Actually the error thrown is something like:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controller' defined in file ...
But it has to be by dependency injection, it fails when create the @Value
in the @Service
and the error is propagated. Also I have tested these values
my:
data:
'{
1:
- 1
- 2,
2:
- 1
}'
And it creates a lists with values -3
and -1
.
| key | value |
+-----+-------+
| 1 | [-3] |
| 2 | [-1] |
+-----+-------+
So the error thrown before has to be due to the definition of the list in the first yml
.
Also I've tested using List<Integer>
and int[]
into the Map
object.
So, what's the correct syntax to create Map<Integer, List<Integer>>
? I assumed it was like a JSON object { key: [v1, v2] }
but it seems to fails.
Thanks in advance.