Update 23.1. Configuring random values.md

master
qibaoguang 2015-02-08 21:51:56 +08:00
parent cdea98c5a0
commit ca40266113
1 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,11 @@
### 23.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此处OPENCLOSE可以是任何字符并且valuemax是整数。如果提供max那么value是最小的值max是最大的值不包含在内