> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/iv.-spring-boot-features/24.-externalized-configuration/24.1.-configuring-random-values.md).

# 24.1. 配置随机值

在注入随机值（比如，密钥或测试用例）时`RandomValuePropertySource`很有用，它能产生整数，longs或字符串，比如：

```java
my.secret=${random.value}
my.number=${random.int}
my.bignumber=${random.long}
my.number.less.than.ten=${random.int(10)}
my.number.in.range=${random.int[1024,65536]}
```

`random.int*`语法是`OPEN value (,max) CLOSE`，此处`OPEN，CLOSE`可以是任何字符，并且`value，max`是整数。如果提供`max`，那么`value`是最小值，`max`是最大值（不包含在内）。
