Spring 属性可以从环境变量绑定(bind):https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config.typesafe-configuration-properties.relaxed-binding.environment-variables
我尝试过各种形式的 null
、NULL
、#{null}
但总是以 fail to conversion 结束java.lang.String 到 java.time.Duration(由 java.lang.IllegalArgumentException 引起:'null' 不是有效的持续时间)
如何从环境变量中设置 null
值?
最佳答案
您不能从环境变量(或任何其他属性源)设置空值。 This Spring Boot issue正在跟踪添加对绑定(bind) null
值的支持。
关于java - 如何将环境变量中的 spring 属性设置为空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73645965/