Spring Boot允許在不同的端口號上多次運行相同的應用程式。 在本章中,將詳細瞭解和學習這一點。 請注意,默認端口號為:8080
。
自定義端口
在application.properties
檔中,屬性server.port
設置自定義端口號:
server.port = 9090
在application.yml檔中,使用以下 -
server:
port: 9090
隨機端口
在application.properties 檔中,server.port
屬性設置隨機端口號:
server.port = 0
在application.yml 檔中,找到如下內容 -
server:
port: 0
注 - 如果啟動Spring Boot應用程式時server.port
指定值為0
,則Tomcat使用隨機端口號。
上一篇:
Spring Boot Servlet篩檢程式
下一篇:
Spring Boot Rest範本