CachedRandomPropertySource
Spring Cloud Context 提供了一个 PropertySource
,它基于键缓存随机值。 除了缓存功能外,它的工作方式与 Spring Boot 的 RandomValuePropertySource
相同。 在您希望随机值即使在 Spring 应用程序上下文重启后仍然保持一致的情况下,此随机值可能很有用。 属性值采用 cachedrandom.[yourkey].[type]
的形式,其中 yourkey
是缓存中的键。 type
值可以是 Spring Boot 的 RandomValuePropertySource
支持的任何类型。
myrandom=${cachedrandom.appname.value}