码迷,mamicode.com
首页 > 编程语言 > 详细

spring打包jar包时jsp页面无法访问

时间:2020-05-12 17:07:33      阅读:54      评论:0      收藏:0      [点我收藏+]

标签:resources   display   插件   creat   targe   table   info   hide   执行   

技术图片

 

 当前pom.xml配置

 

技术图片
<build>
        <resources>
            <!--引入配置文件-->
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
            </resource>
            <!--引入静态文件-->
            <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>
View Code

解决办法:

1.高版本的插件不支持jsp,给spring-boot-maven-plugin指定版本号“1.4.2.RELEASE”

技术图片
<build>
        <resources>
            <!--引入配置文件-->
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
            </resource>
            <!--引入静态文件-->
            <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>
View Code

2.根据spring官网说明,可打包war包,仍然可使用jar -jar xxx.war执行。

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.
View Code

<packaging>war</packaging>

 

 

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-documentation

 

spring打包jar包时jsp页面无法访问

标签:resources   display   插件   creat   targe   table   info   hide   执行   

原文地址:https://www.cnblogs.com/labing/p/12877022.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!