第一种: server.port=0 第二种: //自定义一个范围 server.port=${random.int[1024,9999]} 转载于:https://www.cnblogs.com/anny0404/p/11009691.html