Is it possible with Spring Boot to serve up JSPs with a JAR packaging?

前端 未结 3 1249
北海茫月
北海茫月 2020-11-28 10:25

I\'m familiar with the Spring Boot JSP sample application

However that example uses the WAR packaging. Is it possible to do the same with

3条回答
  •  暖寄归人
    2020-11-28 11:19

    As @Andy Wilkinson said, there are limitations related to JSP. Please package your application as war and execute as jar. This is documented at spring site.

    With Tomcat it should work if you use war packaging, i.e. an executable war will work (...). An executable jar will not work because of a hard coded file pattern in Tomcat.

    • 27.3.5 JSP limitations
    • jsp sample

    Deprecated, old answer

    Yes, this is possible with Spring Boot.

    Take look at this example: https://github.com/mariuszs/spring-boot-web-jsp-example.

    For doing this use spring-boot-maven-plugin or gradle equivalent.

    With this plugin jar is executable and can serve JSP files.

    $ mvn package
    $ java -jar target/mymodule-0.0.1-SNAPSHOT.jar 
    

    or just

    $ mvn spring-boot:run
    

提交回复
热议问题