Deserialize a list from application.yml to @Value in Spring MVC

Viewed 31

I have an old Spring MVC project (not Spring Boot, otherwise it would be easy) with the next configuration in application.yml

spring-caching:
  enabled: true
  default-ttl: PT10M
  caches:
    - name: cache1
      ttl: PT10M
    - name: cache2
      ttl: PT10M

How can I deserialize this configuration to a variable with @Value? I've tried something like below but no success.

@Value("${spring-caching.caches}")
private String props;

@Value("${spring-caching.caches}")
private List<MyClassNameTtl> props;

@Value("${spring-caching.caches}")
private List<Object> props;
0 Answers
Related