SpringBoot打jar包遇到的xml文件丟失的解決方案
SpringBoot打jar包遇到的xml文件丟失
在pom.xml的build標(biāo)簽中添加如下內(nèi)容
指定資源路徑

<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
SpringBoot打jar包遇到的一些問題
1.訪問不到j(luò)sp頁面
1.1 jar包中沒有jsp文件,報404錯誤
原因:沒有添加jsp打包路徑
解決方案:在pom.xml中添加如下代碼
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>
**/*.java
</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/webapp</directory>
<!--注意此次必須要放在此目錄下才能被訪問到 -->
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
</build>
1.2 還是訪問不到頁面,但不報錯,一直在加載
原因:maven編譯版本問題
解決方案:將版本改為1.4.2.RELEASE(目前只有這個版本打jar包才能解析jsp)
1.3 此時若還報錯
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:repackage (default) on project fulan-demo: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:repackage failed: Unable to find a single main class from the following candidates
原因:沒有指定啟動類的位置
解決方案:在pol.xml中指定啟動類
<properties>
<start-class>com.xxx.xxx.xxxApplication</start-class>
</properties>
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Java設(shè)計模式之代理模式原理及實現(xiàn)代碼分享
這篇文章主要介紹了Java設(shè)計模式之代理模式原理及實現(xiàn)代碼分享,設(shè)計代理模式的定義,靜態(tài)代理,動態(tài)代理,jdk動態(tài)代理實現(xiàn)步驟,原理及源碼等相關(guān)內(nèi)容,具有一定參考價值,需要的朋友可以了解下。2017-11-11
Spring Boot集成mongodb數(shù)據(jù)庫過程解析
這篇文章主要介紹了Spring Boot集成mongodb數(shù)據(jù)庫過程解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-05-05
工作中禁止使用Executors快捷創(chuàng)建線程池原理詳解
這篇文章主要為大家介紹了工作中禁止使用Executors快捷創(chuàng)建線程池原理詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-11-11

