溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

SpringBoot打jar包遇到的xml文件丟失該怎么解決

發(fā)布時間:2021-09-28 09:10:36 來源:億速云 閱讀:165 作者:柒染 欄目:開發(fā)技術(shù)

今天就跟大家聊聊有關(guān)SpringBoot打jar包遇到的xml文件丟失該怎么解決,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

SpringBoot打jar包遇到的xml文件丟失

在pom.xml的build標(biāo)簽中添加如下內(nèi)容

指定資源路徑

SpringBoot打jar包遇到的xml文件丟失該怎么解決

<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>

看完上述內(nèi)容,你們對SpringBoot打jar包遇到的xml文件丟失該怎么解決有進一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI