Spring boot 2 Converting Duration java 8 application.properties

后端 未结 5 1743
抹茶落季
抹茶落季 2021-02-20 08:48

I need to define Duration value (spring.redis.timeout) by application.properties.

I was trying to use one point defined in Spri

5条回答
  •  悲哀的现实
    2021-02-20 09:13

    It's possible to use @Value notation with Spring Expression Language

    @Value("#{T(java.time.Duration).parse('${spring.redis.timeout}')}")
    private Duration timeout;
    

提交回复
热议问题