tomcat - Maven tomcat :run goal and jsf annotation based component/converter/validator scanning

标签 tomcat configuration maven jsf-2

我正在开发一个 JSF 2.0 应用程序 (Mojarra+Primefaces) 并使用 maven 构建环境。在我使用 faces-config.xml 文件注册我的自定义转换器和验证器之前,到目前为止一切顺利。然后我看到了 JSF 2.0 的一些语法糖——基于注释的配置方法。现在我想使用它,而不是 xml 配置文件。一个问题是 Mojarra 没有扫描我的注释类。我发现我需要把 <faces-config ... metadata-complete="false">属性为假。现在它可以工作,但前提是我用 mvn tomcat:run-war 启动我的应用程序目标而不是 mvn tomcat:run 动态项目,开发起来更舒服。 JSP 2.0 的规范说:

If the element in the WEB-INF/faces-config.xml file contains metadata-complete attribute whose value is "true", the implementation must not perform annotation scanning on any classes except for those classes provided by the implementation itself. Otherwise, continue as follows.

If the runtime discovers a conflict between an entry in the Application Configuration Resources and an annotation, the entry in the Application Configuration Resources takes precedence. All classes in WEB-INF/classes must be scanned.

For every jar in the application's WEB-INF/lib directory, if the jar contains a "META-INF/faces-config.xml" file or a file that matches the regular expression ".*.faces-config.xml" (even an empty one), all classes in that jar must be scanned.

但是它没有说明在 maven 构建环境中运行的动态项目:)!有人能解决这个问题吗?

干杯,

凯文

最佳答案

我也有这个问题,但发现添加 war:inplace 目标使它对我有用。即使用

mvn clean war:inplace tomcat:run

而不仅仅是“tomcat:run”,它应该可以正常工作。

关于tomcat - Maven tomcat :run goal and jsf annotation based component/converter/validator scanning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4409148/

相关文章:

file - 从网页访问服务器上的文件

java - Tomcat 具有同一应用程序的多个实例

ios - 具有 MDM 负载的配置描述文件未安装到设备

configuration - 如何在tomcat启动时加载配置文件

java - 从 eclipse 使用 tomcat 服务器运行 web 项目

java - 在 Tomcat 中部署后来自 servlet 过滤器的 JSP 文件路径

python - 使用 Python 自动更新 SSH 配置文件的首选方法?

java - maven 按 scp 上传文件

java - 在 Azure Devops CI/CD 管道中使用 JAVA 运行自动化 Selenium Web 驱动程序 UI 测试

java - JpaRepository findAll 返回空列表