国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Springboot 使用thymeleaf 服務(wù)器無法加載resources中的靜態(tài)資源異常處理

這篇具有很好參考價(jià)值的文章主要介紹了Springboot 使用thymeleaf 服務(wù)器無法加載resources中的靜態(tài)資源異常處理。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

一、異常錯(cuò)誤

Springboot使用thymeleaf,并連接遠(yuǎn)程數(shù)據(jù)庫啟動(dòng)時(shí),無法加載resources中的靜態(tài)資源

瀏覽器報(bào)錯(cuò)

Failed to load resource: the server responded with a status of 404 ()

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java

后端啟動(dòng)時(shí)報(bào)錯(cuò)

Servlet.service() for servlet [dispatcherServlet] in context with path [/ce] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template 

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java
前端打開頁面時(shí)后端報(bào)錯(cuò)

Exception processing template "/web/studyOutline/studyOutline": Error resolving template [/web/studyOutline/studyOutline], template might not exist or might not be accessible by any of the configured Template Resolvers

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java

二、原因

打包編譯項(xiàng)目,顯示找不到j(luò)s、css、html等靜態(tài)資源,但本地路徑并沒有寫錯(cuò),于是我去找編譯文件,查看是不是靜態(tài)資源沒有編譯到,打開項(xiàng)目下的target文件夾

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java
前往classes文件夾,發(fā)現(xiàn)項(xiàng)目resources下對(duì)應(yīng)的templates韋文件夾沒有編譯到,缺少靜態(tài)資源,當(dāng)然會(huì)報(bào)錯(cuò)了

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java
request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java

三、解決方法

方法1. 將無法編譯的靜態(tài)資源放入可編譯目錄下

既然服務(wù)器不能編譯templates文件夾,那么把templates文件夾放入calsses路徑下即可,這樣處理就能獲取templats下的靜態(tài)資源了,但如果靜態(tài)資源有改動(dòng),需要手動(dòng)放入classes文件夾下,再次啟動(dòng)項(xiàng)目即可讀取資源

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java
如果再次啟動(dòng)項(xiàng)目,還是顯示找不到j(luò)s、css、html等靜態(tài)資源,請(qǐng)看方法2

方法2. 重新編譯項(xiàng)目加載資源

由于服務(wù)器編譯攔截了靜態(tài)資源,導(dǎo)致出現(xiàn)異常,需要重新打包編譯

打開IDEA帶的Maven管理,雙擊clean清除由項(xiàng)目編譯創(chuàng)建的target

再雙擊install安裝jar包到本地倉(cāng)庫
request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java

項(xiàng)目打包出現(xiàn)異常

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java

系統(tǒng)默認(rèn)編碼是GBK,maven提升需要使用UTF-8,在setting中修改項(xiàng)目編碼為UTF-8

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java

出現(xiàn) Failed to execute goal是由于測(cè)試用例有問題,

 Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-test) on project springboot_04_profile: Input length = 1 -> [Help 1]

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java

選擇跳過測(cè)試用例

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java

再次雙擊install,編譯成功,啟動(dòng)項(xiàng)目即可讀取靜態(tài)資源

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java
如果設(shè)置編碼還是打包失敗,或者顯示找不到j(luò)s、css、html等靜態(tài)資源,請(qǐng)看方法3

方法3. 修改pom.xml資源配置文件

如果設(shè)置編碼還是打包失敗,或者顯示找不到j(luò)s、css、html等靜態(tài)資源,說明服務(wù)器沒有訪問資源的權(quán)限,需要在pom.xml的build下引入資源文件

<!--           引入靜態(tài)資源文件   -->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.css</include>
                    <include>**/*.js</include>
                    <include>**/*.html</include>
                    <include>**/*.png</include>
                    <include>**/*.properties</include>
                    <include>**/*.yml</include>
                    <include>**/*.xml</include>
                    <include>**/*.conf</include>
                </includes>
            </resource>
        </resources>

再次insall,顯示打包成功,瀏覽器404的問題也解決了,加載了靜態(tài)資源

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java

方法4. 不連接遠(yuǎn)程數(shù)據(jù)庫啟動(dòng),使用本地?cái)?shù)據(jù)庫

開頭說了,Springboot使用thymeleaf,并連接遠(yuǎn)程數(shù)據(jù)庫啟動(dòng)時(shí),無法加載resources中的靜態(tài)資源,這是一個(gè)大坑,如果不連接遠(yuǎn)程數(shù)據(jù)庫啟動(dòng),則不存在服務(wù)器訪問資源的問題

打開application.properties配置文件,注釋掉連接遠(yuǎn)程數(shù)據(jù)庫的代碼,改用本地?cái)?shù)據(jù)庫,就不會(huì)有訪問資源的問題了,可以直接加載,瀏覽器不再出現(xiàn)Failed to load resource問題

request processing failed; nested exception is org.thymeleaf.exceptions.temp,Java Spring,spring boot,服務(wù)器,java

異常索引文章來源地址http://www.zghlxwxcb.cn/news/detail-763240.html

  • Failed to load resource: the server responded with a status of 404 ()
  • Servlet.service() for servlet [dispatcherServlet] in context with path [/ce] threw exception [Request processing failed; nested
    exception is org.thymeleaf.exceptions.TemplateInputException: Error
    resolving template
  • Exception processing template “/web/studyOutline/studyOutline”: Error resolving template [/web/studyOutline/studyOutline], template
    might not exist or might not be accessible by any of the configured
    Template Resolvers
  • [INFO] Using ‘UTF-8’ encoding to copy filtered resources. [INFO] Using ‘UTF-8’ encoding to copy filtered properties files.
  • Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources
    (default-test) on project springboot_04_profile: Input length = 1 ->
    [Help 1]

到了這里,關(guān)于Springboot 使用thymeleaf 服務(wù)器無法加載resources中的靜態(tài)資源異常處理的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 解決國(guó)內(nèi)Linux服務(wù)器無法使用Github的方法

    解決國(guó)內(nèi)Linux服務(wù)器無法使用Github的方法

    解決思路:修改Host https://www.ipaddress.com/ 利用上面的網(wǎng)站查詢github.com和raw.githubusercontent.com的DNS解析的IP地址 最后,修改服務(wù)器的/etc/hosts 添加如下兩行: 140.82.112.3 github.com 185.199.108.133 raw.githubusercontent.com 這是最新的IP地址,如果更改之后還無法git clone的話,可能IP地址又更新

    2024年01月20日
    瀏覽(99)
  • 內(nèi)網(wǎng)服務(wù)器(無法聯(lián)網(wǎng))使用docker搭建自己的NAS服務(wù)(filebrowser)

    內(nèi)網(wǎng)服務(wù)器(無法聯(lián)網(wǎng))使用docker搭建自己的NAS服務(wù)(filebrowser)

    課題組內(nèi)有一臺(tái)內(nèi)網(wǎng)部署的ubuntu 23服務(wù)器,想要在上面運(yùn)行一個(gè)NAS服務(wù),供內(nèi)網(wǎng)環(huán)境中的文件存儲(chǔ)與分享。希望搭建一個(gè)功能簡(jiǎn)單、容易上手的NAS服務(wù),并且希望通過docker部署,減少對(duì)于服務(wù)器上現(xiàn)有應(yīng)用的影響。另外,內(nèi)網(wǎng)服務(wù)器意味著它無法連接互聯(lián)網(wǎng)下載應(yīng)用,只能在

    2024年03月16日
    瀏覽(36)
  • 解決websocket在部署到服務(wù)器https下無法使用的問題

    解決websocket在部署到服務(wù)器https下無法使用的問題

    目錄 一、問題 1.1 問題描述 1.2 問題詳細(xì)描述 二、解決 2.1 https下的鏈接類型 2.2 修改Nginx的配置 一個(gè)小項(xiàng)目中使用到了websocket,這個(gè)websocket在本地完全是完全正常運(yùn)行的,不管是 前后臺(tái)的信息通訊? 還是 異常報(bào)錯(cuò)接收 , 無任何異常 ,但當(dāng)把后臺(tái)代碼部署到阿里云服務(wù)器后

    2024年02月09日
    瀏覽(22)
  • 網(wǎng)上鄰居打不開提示工作組的服務(wù)器列表無法使用

    小編的好友說之前能通過網(wǎng)上鄰居瀏覽別人的共享文件,不知道怎么了,最近一直無法打開網(wǎng)上鄰居.提示“此工作組的服務(wù)器列表當(dāng)前無法使用”,重啟幾次都無法解決.是什么原因. 一些軟件的開機(jī)加速優(yōu)化會(huì)建議禁止“Gomputer Browser(計(jì)算機(jī)列表)”這個(gè)服務(wù),沒有這個(gè)服務(wù)就可能

    2024年02月06日
    瀏覽(23)
  • SpringBoot如何使用MultipartFile進(jìn)行文件上傳保存到服務(wù)器本地

    之前一直都是用的別人封裝好的文件上傳方法,這次想自己寫一個(gè)特別簡(jiǎn)單的,文件上傳方法,非常適合新手觀看… 首先需要Springboot需要有Web依賴,就是下面這個(gè)依賴 依賴導(dǎo)完了,下面就直接是代碼,大家看一下 到這里文件上傳的解釋都在代碼里面,下面如果報(bào)文件過大的報(bào)錯(cuò)還需

    2024年02月13日
    瀏覽(30)
  • Linux中關(guān)于glibc包導(dǎo)致的服務(wù)器死機(jī)或者linux命令無法使用的情況

    Linux中關(guān)于glibc包導(dǎo)致的服務(wù)器死機(jī)或者linux命令無法使用的情況

    glibc是gnu發(fā)布的libc庫,即c運(yùn)行庫。 glibc是linux系統(tǒng)中最底層的api,幾乎其它任何運(yùn)行庫都會(huì)依賴于glibc 。glibc除了封裝linux操作系統(tǒng)所提供的系統(tǒng)服務(wù)外,它本身也提供了許多其它一些必要功能服務(wù)的實(shí)現(xiàn)。由于 glibc 囊括了幾乎所有的 UNIX 通行的標(biāo)準(zhǔn),可以想見其內(nèi)容包羅萬

    2024年02月03日
    瀏覽(44)
  • MySQL 的服務(wù)器安裝及使用,springboot源碼深度解析pdf

    MySQL 的服務(wù)器安裝及使用,springboot源碼深度解析pdf

    SELECT * FROM users WHERE uname in (‘zs’,‘ls’) 排序 order by 要寫在 sql 語句的最后 – asc 升序 desc 降序 SELECT * FROM users ORDER BY DESC SELECT * FROM users WHERE uage 18 ORDER by desc 限制查詢條數(shù) – 取前3條數(shù)據(jù) SELECT * FROM users LIMIT 3 – 降序后去3條數(shù)據(jù) SELECT * FROM users ORDER BY DESC LIMIT 3 – 跳過3條,

    2024年04月14日
    瀏覽(20)
  • 云服務(wù)器使用jenkins+docker自動(dòng)化部署SpringBoot項(xiàng)目

    云服務(wù)器使用jenkins+docker自動(dòng)化部署SpringBoot項(xiàng)目

    docker?安裝jenkins,就這一步都惡心死了 //拉取鏡像,踩了很多坑,用其它版本的鏡像插件一直安裝失敗,最后用的是lts版本(基礎(chǔ)版) 用其它版本要么是連不上插件的下載地址,要么是插件下載不成功 ?docker pull jenkins/jenkins:lts ?部署 docker run --user root -d -p 10240:8080 -p 10241:50

    2024年02月01日
    瀏覽(30)
  • Springboot中使用內(nèi)嵌服務(wù)器運(yùn)行 WAR 文件的探索之路

    ???? 博主貓頭虎 帶您 Go to New World.??? ?? 博客首頁——貓頭虎的博客?? ??《面試題大全專欄》 文章圖文并茂??生動(dòng)形象??簡(jiǎn)單易學(xué)!歡迎大家來踩踩~?? ?? 《IDEA開發(fā)秘籍專欄》學(xué)會(huì)IDEA常用操作,工作效率翻倍~?? ?? 《100天精通Golang(基礎(chǔ)入門篇)》學(xué)會(huì)Golang語言

    2024年02月21日
    瀏覽(17)
  • 手動(dòng)將Java SpringBoot項(xiàng)目部署到云服務(wù)器上(使用docker)

    手動(dòng)將Java SpringBoot項(xiàng)目部署到云服務(wù)器上(使用docker)

    本文記錄一下我作為一個(gè)小白如何通過docker手動(dòng)將java springboot項(xiàng)目部署到云服務(wù)器上(以騰訊云的輕量應(yīng)用服務(wù)器為例)。 但是我個(gè)人還是推薦安裝一個(gè)寶塔面板部署 ,真的全程自動(dòng)化,非常方便,網(wǎng)上有很多相關(guān)的教程可以搜搜看。所以我寫這個(gè)教程其實(shí)只想記錄一下我

    2024年04月25日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包