Spring Boot是否可以使用JAR包装来提供JSP [英] Is it possible with Spring Boot to serve up JSPs with a JAR packaging
问题描述
我熟悉Spring Boot JSP示例应用程序
但是该示例使用 WAR
打包。是否可以使用< packaging> JAR< / packaging>
?
我的目标是把 JSP
放在 src / main / resources / jsp
下,以简化我的应用程序的结构。
正如@Andy Wilkinson所说,存在与JSP相关的限制。请将您的应用程序打包为 war
并执行 jar
。这是在春季站点记录的。
使用Tomcat它应该可以使用war包装,即可执行的战争将起作用(... )。 由于Tomcat中的硬编码文件模式,可执行jar将无法工作。
已弃用,旧答案
是的,这可以通过Spring Boot实现。
看一下这个例子: https://github.com / mariuszs / spring-boot-web-jsp-example 。
为此,请使用 spring-boot-maven-plugin 或gradle equival这个插件jar是可执行的,可以提供JSP文件。
$ mvn package
$ java -jar target / mymodule-0.0.1-SNAPSHOT.jar
或只是
$ mvn spring-boot:run
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 <packaging>JAR</packaging>
?
My goal is to put JSP
s under src/main/resources/jsp
to simplify the structure of my app.
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.
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
这篇关于Spring Boot是否可以使用JAR包装来提供JSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!