Spring Boot JSF打包为JAR [英] Spring Boot JSF packaging as a JAR
问题描述
我正在尝试使用jsf和gradle创建一个Spring Boot应用程序.
I am trying to create a spring boot app with jsf and gradle.
到目前为止,在开发过程中一切都很好.当我想运行我的应用程序时,我只键入了gradle bootRun,该应用程序就启动了,并且可以在"localhost"下访问它.
So far, during development everything was fine. When I wanted to run my App I just typed gradle bootRun, the app started and I was able to access it under 'localhost'.
现在我正要在某个时间部署应用程序,因此我运行了命令"gradle clean distTar",该命令创建了要部署的tar文件.
Now I am at a point of time, where I want to deploy the app, therefore I run the command 'gradle clean distTar' which creates the tar file to deploy.
运行生成的脚本并通过浏览器访问我的应用程序后,我仅收到带有消息的404.
After running the generated script and accessing my app via Browser I just get an 404 with the message.
index.xhtml Not Found in ExternalContext as a Resource
在jar文件中,也没有包含任何html文件.我用命令将它们包含在罐子中
Also in the jar file, there aren't any html files included. I included them in the jar with the command
from ("${projectDir}/src/main/webapp/"){
into('resources')
}
引用 https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot 此文件应可访问.但是仍然没有任何改变.
Referring to https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot this files should be accessible. But still nothing changed.
还有其他人有线索吗?我在做什么错了?
Does anyone else have a clue? What am I doing wrong?
BR
推荐答案
我也一直在努力解决这个问题,最终设法提出了一个可行的解决方案.
I've been also struggling with this thing and finally managed to come up with a working solution.
如以下内容所述: https://stackoverflow.com/a/9473487/4250114 (如果您使用的是Servlet3.x)(可能与SpringBoot一起使用).
As stated in: https://stackoverflow.com/a/9473487/4250114 if you use Servlet3.x (and you probably are with SpringBoot).
对我来说,maven中的结构如下所示:
For me structure in maven looks like below worked:
src
|-main
| ...
|-resources
|-META-INF
|-faces-config.xml
|-resources
|-test.xhtml
所以在jar中应该是:
So in jar it should be:
|-META-INF
|-faces-config.xml
|-resources
|-test.xhtml
这篇关于Spring Boot JSF打包为JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!