我需要在application.properties中定义Duration值(spring.redis.timeout)。
我尝试使用Spring Boot文档中定义的方法:
Spring Boot专门支持表示时间段。 如果您暴露一个java.time.Duration
属性,则可以在应用程序属性中使用以下格式:
常规长表示形式(使用毫秒作为默认单位,除非指定了@DurationUnit
)
java.util.Duration
使用的标准ISO-8601格式
更易读的格式,其中值和单位耦合在一起(例如,10s表示10秒)
当我使用spring.redis.timeout=3s时,Spring Boot应用程序会抛出此异常:
Cannot convert value of type 'java.lang.String' to required type 'java.time.Duration': no matching editors or conversion strategy found
使用Spring Boot 2最新版本,哪种方式是设置Duration属性的正确值的最佳方法?