问题描述:
-
配置随机端口(看下图)(注意中括号里面,逗号后面有个空格)
代码:server.port = ${random.int[2048, 8096]}
点击运行时,就出现了如下所示的问题:
Description: Failed to bind properties under 'server.port' to java.lang.Integer: Property: server.port Value: ${random.int[2048, 8096]} Origin: class path resource [application.properties]:1:15 Reason: For input string: " 8096" Action: Update your application's configuration Process finished with exit code 1
问题的根源以及解决:
- 问题的根源就是中括号里面,逗号后面有个空格,因为平时写代码符号后面习惯空一格,然后遇到了运行失败的问题,具体是什么原因先记着,以后再深究。
- 解决方法就是删掉逗号后面那样的空格:
server.port = ${random.int[2048,8096]}
运行成功: