天天看點

spring-boot自定義啟動端口

spring boot本身内置tomcat,我們不需要進行tomcat的配置,隻需要引入tomcat的依賴即可.

1.spring boot中自定義端口需要入口類實作configurableembeddedservletcontainer接口.如下代碼

2.直接自定義configurableembeddedservletcontainer.通過自己注冊tomcatembeddedservletcontainerfactory,

jettyembeddedservletcontainerfactory或undertowembeddedservletcontainerfactory

3.在配置檔案中設定

使用application.properties

使用application.yml

長路漫漫,與君共勉!