Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring Boot JSF打包为JAR_Java_Spring_Jsf_Gradle_Spring Boot - Fatal编程技术网

Java Spring Boot JSF打包为JAR

Java Spring Boot JSF打包为JAR,java,spring,jsf,gradle,spring-boot,Java,Spring,Jsf,Gradle,Spring Boot,我正在尝试用jsf和gradle创建一个SpringBoot应用程序 到目前为止,在开发过程中一切都很好。当我想运行我的应用程序时,我只需输入gradlebootrun,应用程序就启动了,我可以在“localhost”下访问它 现在我正处于一个时间点,我想部署应用程序,因此我运行命令“gradle clean distTar”,它创建要部署的tar文件 在运行生成的脚本并通过浏览器访问我的应用程序后,我只收到一条404消息 index.xhtml Not Found in ExternalCon

我正在尝试用jsf和gradle创建一个SpringBoot应用程序

到目前为止,在开发过程中一切都很好。当我想运行我的应用程序时,我只需输入gradlebootrun,应用程序就启动了,我可以在“localhost”下访问它

现在我正处于一个时间点,我想部署应用程序,因此我运行命令“gradle clean distTar”,它创建要部署的tar文件

在运行生成的脚本并通过浏览器访问我的应用程序后,我只收到一条404消息

index.xhtml Not Found in ExternalContext as a Resource
jar文件中也没有包含任何html文件。我用命令将它们包含在jar中

from ("${projectDir}/src/main/webapp/"){
    into('resources')
}
指 这些文件应该是可访问的。但仍然没有改变

还有人有线索吗?我做错了什么


BR

我也一直在努力解决这个问题,最后终于想出了一个可行的解决方案

如中所述:如果您使用Servlet3.x(您可能使用SpringBoot)

对于我来说,maven中的结构如下所示:

src |-main | ... |-resources |-META-INF |-faces-config.xml |-resources |-test.xhtml src |-主要 | ... |-资源 |-META-INF |-faces-config.xml |-资源 |-test.xhtml 所以在jar中应该是:

|-META-INF |-faces-config.xml |-resources |-test.xhtml |-META-INF |-faces-config.xml |-资源 |-test.xhtml 按照给定的结构创建fat jar

基于SpringBoot+Jetty的信息和输出

2018-01-15 15:57:03 [main] INFO  o.j.jetty.JsfJettyServerCustomizer - Setting Jetty classLoader to META-INF/resources directory
我在Gradle文件中使用了这个:

jar {
    baseName = 'csm'
    version = "0.0.1-SNAPSHOT"

    from("build/docs/"){
        into("generated/docs/")
    }
    from("src/main/resources/"){
        include("**")
    }
    // JSF and SpringBoot and Jetty require all webapp files to be in a very particular location.
    // See: https://github.com/spring-projects/spring-boot/issues/8299
    from ("${projectDir}/src/main/webapp/"){
        into('META-INF/resources')
    }
}

/BOOT-INF
/META-INF/
   /resources/
      /WEB-INF/
         web.xml
      index.jsf
      blah.xhtml

同时,将包含所有文件的名为resources的文件夹添加到classpath中也没有帮助……难道没有人知道或者我的问题有那么糟糕吗?这真的让我发疯…顺便说一句:为了完成,我停止调查这个问题。在下面的存储库中,我上传了一个示例项目:对我来说,还有一个关于这个问题的持续讨论。由于SpringMVC自动配置的魔力,DispatcherServlet似乎被重新初始化。请看我最后的评论,因为我目前无法证明你的答案是propper解决方案,我无法将这个问题标记为已解决。不过还是要谢谢你!我会在下周试一试的。好的。我只是添加了答案,因为我花了很多时间寻找解决方案,所以这个答案可能会节省一些时间。希望如此!我一有时间就去试试。目前,我从springBoot切换到在tomcat7上部署*.war文件。
jar {
    baseName = 'csm'
    version = "0.0.1-SNAPSHOT"

    from("build/docs/"){
        into("generated/docs/")
    }
    from("src/main/resources/"){
        include("**")
    }
    // JSF and SpringBoot and Jetty require all webapp files to be in a very particular location.
    // See: https://github.com/spring-projects/spring-boot/issues/8299
    from ("${projectDir}/src/main/webapp/"){
        into('META-INF/resources')
    }
}

/BOOT-INF
/META-INF/
   /resources/
      /WEB-INF/
         web.xml
      index.jsf
      blah.xhtml