我的EL表达式没有在MyFaces 2.3和Spring Boot 2.0.3应用程序下进行评估

我有一个在Spring Boot 2.0.3下运行的MyFaces应用程序,所有ServletsContext Listeners都已正确注册和配置,并且显然正常工作。 甚至我的index.jsf页面也在渲染。 标记在.xhtml文件上正确处理。

问题是index.jsf页面的所有EL expressions都没有被处理/评估。 不会抛出任何错误,但放置#{myBean.property}的地方始终呈现为空String 。 调试它我看到我的Managed bean的服务器代码没有被调用。

我尝试为许多版本更改el-api和el-impl库,但没有人工作。 我使用的最终版本是el-api 2.2规范,遵循页面https://myfaces.apache.org/core23/myfaces-impl/dependencies.html

由于没有抛出错误,我无法弄清楚问题出在哪里。 有人有这个错误吗? 是否可以在作为jar文件打包的Spring Boot应用程序下运行MyFaces 2.3?

以下是我在Gradle构建文件中使用的依赖项:

 dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile("org.jetbrains.kotlin:kotlin-reflect") testCompile group: 'junit', name: 'junit', version: '4.12' testCompile('org.springframework.boot:spring-boot-starter-test') compile 'io.github.microutils:kotlin-logging:1.5.4' compile group: 'org.apache.myfaces.core', name: 'myfaces-impl', version: '2.3.1' compile group: 'org.apache.myfaces.core', name: 'myfaces-api', version: '2.3.1' compile group: 'javax.enterprise', name: 'cdi-api', version: '2.0' //CDI vem embutido no JavaEE 6, mas não no Tomcat 9 compile group: 'org.glassfish.web', name: 'el-impl', version: '2.2' // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot compile 'org.springframework.boot:spring-boot-starter-web:2.0.3.RELEASE' compile 'org.apache.tomcat.embed:tomcat-embed-jasper:8.5.32' compile 'com.fasterxml.jackson.module:jackson-module-kotlin:2.9.6' compile group: 'org.ocpsoft.rewrite', name: 'rewrite-servlet', version: '3.4.2.Final' } 

这是Spring配置,用于加载Faces servlet:

 @Component open class ConfigureJSF : ServletContextInitializer { private val logger = KotlinLogging.logger {} @Throws(ServletException::class) override fun onStartup(servletContext: ServletContext) { //necessary to myfaces be enabled and work in spring boot, once servlets are loaded dynamically. servletContext.setInitParameter("org.apache.myfaces.INITIALIZE_ALWAYS_STANDALONE", "true") servletContext.setInitParameter("com.sun.faces.forceLoadConfiguration", "true"); servletContext.setInitParameter("javax.faces.FACELETS_SKIP_COMMENTS", "true"); servletContext.setInitParameter("javax.faces.DEFAULT_SUFFIX", ".xhtml") servletContext.setInitParameter("javax.faces.FACELETS_REFRESH_PERIOD", "1") servletContext.setInitParameter("org.apache.myfaces.EXPRESSION_FACTORY", "com.sun.el.ExpressionFactoryImpl") servletContext.setInitParameter("org.apache.myfaces.CACHE_EL_EXPRESSIONS", "alwaysRecompile") } // Register ServletContextListener, necessary for Myfaces. @Bean open fun listenerRegistrationBean1(): ServletListenerRegistrationBean { val bean = ServletListenerRegistrationBean() bean.setListener(org.apache.myfaces.webapp.StartupServletContextListener()) return bean } @Bean fun requestContextListener(): RequestContextListener { return RequestContextListener() } //The faces servlet @Bean open fun facesServlet(): ServletRegistrationBean { logger.info { "Criando Faces Servlet..." } val servlet = org.apache.myfaces.webapp.MyFacesServlet() ; val servletRegistrationBean = ServletRegistrationBean(servlet, "*.jsf", "*.xhtml") servletRegistrationBean.setLoadOnStartup(1) // servletRegistrationBean.order = 1; return servletRegistrationBean; } 

编辑:

我复制了另一个有效的项目的依赖配置,并且发生了相同的结果。 所以,问题不在于我在这里粘贴的代码,是的,在我的环境中,我将开始更详细地研究序列。 我有问题的环境包含JDK 8, 9 and 10以及Tomcat 9 。 我的项目是针对JDK 8 。 也许这里有一些不兼容性,这就是没有找到一些编译注释的原因,我相信我会很快发现这个问题。

经过几天试图解决这个问题,改变和组合不同的代码和环境,从JDK 8 to 10Tomcat 8 and 9 ,在MacOSWindows 10进行测试,从MyFacesJSF 2.1实现到支持CDI全新JSF 2.3实现,我刚刚注意到,在我昂贵的32英寸高分辨率显示器上,我使用一个陌生人角色命名我的Managed Bean并在其顶部有一个小圆点,这是一个diarised ï我不知道它是如何放置或打字的。 这就是我无论在哪种配置下都找不到托管bean的原因。

我在MacOS上注意到了这个角色。 在我的Windows上,似乎更难注意到它。 我认为这是因为字体差异,而不是硬件。

奇怪的ï,花了我一个星期

我很惭愧,但我不会删除这个问题。 愿这可以帮助将来的某个人。 编程和生活问题是这样的:大多数时候错误是在较不期望的地方。

学过的知识。