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

<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.訪問不到jsp頁面
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)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Java的web開發(fā)中SSH框架的協(xié)作處理應用筆記
這篇文章主要介紹了Java的web開發(fā)中SSH框架的協(xié)作處理應用筆記,SSH是指Struts和Spring以及Hibernate的框架搭配,需要的朋友可以參考下2015-12-12
SpringBoot之logback-spring.xml不生效的解決方法
這篇文章主要介紹了SpringBoot之logback-spring.xml不生效的解決方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-01-01
Springboot整合Mybatis和SQLite的詳細過程
這篇文章主要介紹了Springboot整合Mybatis和SQLite的詳細過程,本文通過圖文示例相結合給大家介紹的非常詳細,感興趣的朋友跟隨小編一起看看吧2024-07-07

