Spring打包jar包時(shí)jsp頁(yè)面無(wú)法訪問(wèn)問(wèn)題解決
spring打包jar包時(shí)jsp頁(yè)面無(wú)法訪問(wèn)
問(wèn)題如下
當(dāng)前pom.xml配置
<build> <resources> <!--引入配置文件--> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> </resource> <!--引入靜態(tài)文件--> <resource> <directory>src/main/webapp</directory> <targetPath>META-INF/resources</targetPath> <filtering>false</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> </build>
解決辦法:
1.高版本的插件不支持jsp,給spring-boot-maven-plugin指定版本號(hào)“1.4.2.RELEASE”
<build> <resources> <!--引入配置文件--> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> </resource> <!--引入靜態(tài)文件--> <resource> <directory>src/main/webapp</directory> <targetPath>META-INF/resources</targetPath> <filtering>false</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.4.2.RELEASE</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> </build>
2.根據(jù)spring官網(wǎng)說(shuō)明,可打包war包,仍然可使用jar -jar xxx.war執(zhí)行。
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-jsp-limitations
JSP Limitations When running a Spring Boot application that uses an embedded servlet container (and is packaged as an executable archive), there are some limitations in the JSP support. With Jetty and Tomcat, it should work if you use war packaging. An executable war will work when launched with java -jar, and will also be deployable to any standard container. JSPs are not supported when using an executable jar. Undertow does not support JSPs. Creating a custom error.jsp page does not override the default view for error handling. Custom error pages should be used instead.
<packaging>war</packaging>
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-documentation
spring官方不推薦使用jsp,推薦使用thymeleaf、freemaker、velocity等其他模塊引擎。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Spring Boot jar中沒(méi)有主清單屬性的解決方法
- Springboot jar文件如何打包zip在linux環(huán)境運(yùn)行
- Spring Boot 的java -jar命令啟動(dòng)原理詳解
- 解決idea中Springboot找不到BASE64Encoder或Decoder的jar包
- springboot web項(xiàng)目打jar或者war包并運(yùn)行的實(shí)現(xiàn)
- 簡(jiǎn)單了解springboot的jar包部署步驟
- SpringBoot項(xiàng)目沒(méi)有把依賴(lài)的jar包一起打包的問(wèn)題解決
- Linux 啟動(dòng)停止SpringBoot jar 程序部署Shell 腳本的方法
相關(guān)文章
Java數(shù)據(jù)結(jié)構(gòu)之圖(動(dòng)力節(jié)點(diǎn)Java學(xué)院整理)
本文章主要講解學(xué)習(xí)如何使用JAVA語(yǔ)言以鄰接表的方式實(shí)現(xiàn)了數(shù)據(jù)結(jié)構(gòu)---圖(Graph)。對(duì)java數(shù)據(jù)結(jié)構(gòu)之圖相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧2017-04-04springboot多模塊項(xiàng)目mvn打包遇到存在依賴(lài)但卻無(wú)法發(fā)現(xiàn)符號(hào)問(wèn)題
在SpringBoot多模塊項(xiàng)目中,如果遇到依賴(lài)存在但無(wú)法發(fā)現(xiàn)符號(hào)的問(wèn)題,常見(jiàn)原因可能是pom.xml配置問(wèn)題,例如,如果某個(gè)模塊僅作為依賴(lài)而不是啟動(dòng)工程,不應(yīng)在其pom中配置spring-boot-maven-plugin插件,因?yàn)檫@將影響jar包的生成方式2024-09-09Java 可視化垃圾回收_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
Ben Evans是一名資深培訓(xùn)師兼顧問(wèn),他在演講可視化垃圾回收中從基礎(chǔ)談起討論了垃圾回收。以下是對(duì)其演講的簡(jiǎn)短總結(jié)。感興趣的朋友一起學(xué)習(xí)吧2017-05-05