CachedRandomPropertySource

Spring Cloud Context 提供了一個 PropertySource,它基於鍵快取隨機值。 除了快取功能外,它的工作方式與 Spring Boot 的 RandomValuePropertySource 相同。 在您希望隨機值即使在 Spring 應用程式上下文重啟後仍然保持一致的情況下,此隨機值可能很有用。 屬性值採用 cachedrandom.[yourkey].[type] 的形式,其中 yourkey 是快取中的鍵。 type 值可以是 Spring Boot 的 RandomValuePropertySource 支援的任何型別。

myrandom=${cachedrandom.appname.value}