spring boot設定靜態檔案路徑

2021-09-17 20:45:27 字數 632 閱讀 4461

在專案開發過程中,時間比較緊急,專案組拿了乙個同事之前的一套bsm(後台管理系統)**,基於spring-boot和angular的,前後臺沒有分離,遇到乙個很神奇的問題,就是在eclipse中,更改靜態檔案html、js後可以自動熱載入,但是在intellij裡面卻不行,研究了一下,解決辦法如下

即將存放靜態檔案的目錄設定為resources

如圖:在intellij裡面,找到file-project structure,設定即可

ps:注意這種方式在開發過程中很方便,會將所有請求路徑對映到目錄。最好的方式是將靜態檔案放在resources目錄下面,spring-boot找靜態檔案的預設路徑是:classpath:/static,classpath:/public,classpath:/resources,classpath:/meta-inf/resources

springboot 訪問靜態資源設定

今天乙個人問我為什麼專案下的不能訪問,幫他解決問題後我決定記錄下來,springboot 的程式的靜態資源訪問需要重寫addresourcehandlers方法,直接上 import org.springframework.context.annotation.configuration impor...

springboot設定靜態資源不攔截的方法

1.層面,springboot不攔截靜態資源需配置 import org.springframework.web.servlet.config.annotation.resourcehandlerregistry import org.springframework.web.servlet.conf...

SpringBoot靜態動態

在src main resources下面有兩個資料夾,static和templates springboot預設 static中放靜態頁面,而templates中放動態頁面 靜態頁面 這裡我們直接在static放乙個hello.html,然後直接輸入http localhost 8080 hell...