在
properties或yaml配置文件中是可以使用占位符的
1、随机数
${random.value}- 类似uuid的随机数,没有"-"连接${random.int}- 随机取整型范围内的一个值${random.long}- 随机取长整型范围内的一个值${random.long(100,200)}- 随机生成长整型100-200范围内的一个值${random.uuid}- 生成一个uuid,有短杠连接${random.int(10)}- 随机生成一个10以内的数${random.int(100,200)}- 随机生成一个100-200范围以内的数
例子
#user.username=${random.value}
#user.username=${random.int}
#user.username=${random.long}
#user.username=${random.uuid}
#user.username=${random.int(10)}
#user.username=${random.int(100,200)}
user.username=${random.long(100,200)}
2、占位符
${key:defaultValue}- 若key不存在,则将defaultValue的值赋值给取值的对象
例子
${user.username}当在配置文件中用这个表达式,而user.username未定义的时候,取值时会将${user.username}当做字符串处理
user.username=${test.xx:周伯通}