如何使JSF与docker容器中的spring-boot应用程序一起使用? [英] How to get JSF working with spring-boot app in docker container?

查看:128
本文介绍了如何使JSF与docker容器中的spring-boot应用程序一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用spring-boot 1.4.0和JSF 2.2(Mojarra 2.2.13)构建的应用程序,该应用程序在嵌入式tomcat(8.5)上运行.

I have an app built with spring-boot 1.4.0 and JSF 2.2 (Mojarra 2.2.13) running on embedded tomcat (8.5).

当我在本地运行 应用程序时,它运行良好-不管我是使用mvn spring-boot:run还是java -jar target/myapp.jar

When I run the app locally, it works fine - regardless of whether I start it from my IDE, with mvn spring-boot:run or java -jar target/myapp.jar

但是,当我在Docker容器内启动应用程序(使用docker 1.12.1)时,对于JSF页面,除外一切正常.例如,像/health这样的spring-boot-actuator页面工作正常,但是当尝试访问/home.xhtml(JSF页面)时,我得到:

However, when I start the app inside a docker container (using docker 1.12.1) everything works except for the JSF pages. For example the spring-boot-actuator pages like /health work just fine but when trying to access /home.xhtml (a JSF page) I get:

白标错误页面

此应用程序没有/error的显式映射,因此您将其视为后备.

This application has no explicit mapping for /error, so you are seeing this as a fallback.

2016年10月12日星期三09:33:33 GMT 发生意外错误(类型=未找到,状态= 404). /home.xhtml Not Found in ExternalContext as a Resource

Wed Oct 12 09:33:33 GMT 2016 There was an unexpected error (type=Not Found, status=404). /home.xhtml Not Found in ExternalContext as a Resource

我使用io.fabric8:docker-maven-plugin来构建docker映像(基于带有openjdk-8-jre的alpine),其中包括docker容器内/maven下的构建工件,以及java -jar /maven/${project.artifactId}-${project.version}.jar来启动应用程序.

I use io.fabric8:docker-maven-plugin to build the docker image (based on alpine with openjdk-8-jre), which includes the build artifact under /maven inside the docker container and java -jar /maven/${project.artifactId}-${project.version}.jar to start the app.

我使用的是端口9000,而不是标准的tomcat端口(8080),并且该端口也由docker映像公开.

I am using port 9000 instead of the standard tomcat port (8080) and this is also exposed by the docker image.

我已经比较了本地jar和docker容器中包含的jar,它们都有相同的内容.

I already compared both the local jar and the one included in the docker container and they both have the same content.

任何帮助将不胜感激. 预先感谢

Any help would be appreciated. Thanks in advance

推荐答案

XHTML文件和其余JSF文件放置在错误的目录中.

XHTML files and the rest of the JSF files was placed in the wrong directory.

至少在使用<packaging>jar</packaging>时,似乎所有JSF内容都必须放置在src/main/resources/META-INF下,而不是大多数IDE将自动放置在src/main/webapp下.

At least when using <packaging>jar</packaging> it appears that all JSF stuff must be placed under src/main/resources/META-INF instead of src/main/webapp where most IDEs will automatically place it.

src/main/webapp中包含JSF内容时,它不会包含在(或不在正确的位置)到spring-boot-repackaged的jar文件中.

When JSF stuff is in src/main/webapp it does not get included (or not in the right place) into the spring-boot-repackaged jar file.

我的src/main/resources现在看起来像这样:

My src/main/resources looks like this now:

src
└── main
    └── resources
        ├── application.yml
        └── META-INF
            ├── faces-config.xml
            └── resources
                ├── administration
                │   └── userlist.xhtml
                ├── css
                │   └── default.css
                ├── images
                │   └── logo.png
                └── home.xhtml

这篇关于如何使JSF与docker容器中的spring-boot应用程序一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆