配置spring boot內建web容器

2021-08-20 05:30:31 字數 1383 閱讀 2621

1、對server的幾個常用的配置做個簡單說明:

# 專案contextpath,一般在正式發布版本中,我們不配置  

server.context-path=/myspringboot

# 錯誤頁,指定發生錯誤時,跳轉的url。請檢視basicerrorcontroller原始碼便知

server.error.path=/error

# 服務埠

server.port=9090

# session最大超時時間(分鐘),預設為30

server.session-timeout=60

# 該服務繫結ip位址,啟動伺服器時如本機不是該ip位址則丟擲異常啟動失敗,只有特殊需求的情況下才配置

# server.address=192.168.16.11

2、tomcat為spring boot的預設容器,下面是幾個常用配置:

1)pom.xml依賴配置:

org.springframework.boot

spring-boot-starter-tomcat

2)tomcat配置

# tomcat最大執行緒數,預設為200  

server.tomcat.max-threads=800

# tomcat的uri編碼

server.tomcat.uri-encoding=utf-8

server.tomcat.basedir=h:/springboot-tomcat-tmp

# 開啟tomcat的access日誌,並可以設定日誌格式的方法:

#server.tomcat.access-log-enabled=true

#server.tomcat.access-log-pattern=

# accesslog目錄,預設在basedir/logs

#server.tomcat.accesslog.directory=

# 日誌檔案目錄

logging.path=h:/springboot-tomcat-tmp

# 日誌檔名稱,預設為spring.log

3、如果你要選擇jetty,也非常簡單,就是把pom中的tomcat依賴排除,並加入jetty容器的依賴,如下:

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-tomcat

org.springframework.boot

spring-boot-starter-jetty

SpringBoot內建tomcat配置SSL證書

1.將阿里雲網域名稱 cyclothe.com 解析成www.cyclothe.com 到你的伺服器下 2.將網域名稱對應的443 80 埠開發安全組,瀏覽器預設對80埠隱藏 5.配置你的yml檔案 server port 443 服務埠 ssl key store password 你的證書密碼 ...

springboot內建tomcat配置虛擬路徑

在springboot中預設的靜態資源路徑有 classpath metainf resources classpath resources classpath static classpath public 從這裡可以看出這裡的靜態資源路徑都是在classpath中 也就是在專案路徑下指定的這幾個...

內建配置讀者

class phpreader可以讀取配置檔案儲存為純php檔案。你可以讀檔案從你的應用程式 配置或外掛程式配置目錄通過使用外掛程式語法。檔案必須包含乙個 配置變數。乙個示例配置檔案會看起來像 config array debug 0,security array salt its secret e...