在 application.properties 中配置属性时,可以使用随机数。原因是springboot启动时,将random配置属性类RandomValuePropertySource自动装配,使得在加载配置文件时,可以解析${random.value}。
该类提供随机整形、长整形数、UUID 或者字符串。
示例如下:
my.secret=${random.value}
my.number=${random.int}
my.bignumber=${random.long}
my.uuid=${random.uuid}
my.number.less.than.ten=${random.int(10)}
my.number.in.range=${random.int[1024,65536]}