跳到主要内容

缓存随机属性源

DeepSeek V3 中英对照 CachedRandomPropertySource

Spring Cloud Context 提供了一个 PropertySource,它基于键缓存随机值。除了缓存功能外,它的工作方式与 Spring Boot 的 RandomValuePropertySource 相同。这个随机值在你希望获得一个即使在 Spring 应用上下文重启后仍然一致的随机值时可能很有用。属性值的格式为 cachedrandom.[yourkey].[type],其中 yourkey 是缓存中的键。type 值可以是 Spring Boot 的 RandomValuePropertySource 支持的任何类型。

myrandom=${cachedrandom.appname.value}
properties