spring-boot - 将 Primefaces 与 Springboot/JoinFaces 集成时出错
问题描述
我正在尝试按照以下教程创建一个将primefaces与spring boot集成的应用程序:
https://codenotfound.com/jsf-primefaces-example.html
我按照教程的建议添加了连接面:
这是我的 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.M3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.dataprev.election</groupId>
<artifactId>election</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>election</name>
<description>Demo System Election</description>
<properties>
<java.version>13</java.version>
<joinfaces.version>4.1.5</joinfaces.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>jsf-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>joinfaces-dependencies</artifactId>
<version>${joinfaces.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>
</project>
我创建了 webapp/WEB-INF 文件夹结构:
正如您在图像上看到的那样,webapp 文件夹看起来不像 intellij 识别的那样。
其他问题是您在图像上看到的 xmlns:p="http://primefaces.org/ui" url taglib 未被识别。
所以当我在浏览器上运行时:http://localhost:8080/eleicao.xhtml 浏览器返回错误:
出现意外错误(类型=未找到,状态=404)。/eleicao.xhtml 在 ExternalContext 中未找到作为资源
那么我该如何解决呢?这样我就可以运行 primefaces 页面。
解决方案
您在这里缺少一堆依赖项,这是我的 PrimeFaces 的 pom、JSF 的 MyFaces、OmniFaces 和作为 servlet 引擎的 Undertow
<!-- JoinFaces -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>primefaces-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.joinfaces</groupId>
<artifactId>tomcat-spring-boot-starter</artifactId>
</exclusion>
<exclusion>
<groupId>org.joinfaces</groupId>
<artifactId>mojarra-spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>omnifaces3-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.joinfaces</groupId>
<artifactId>tomcat-spring-boot-starter</artifactId>
</exclusion>
<exclusion>
<groupId>org.joinfaces</groupId>
<artifactId>mojarra-spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>undertow-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>myfaces-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>rewrite-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>weld-spring-boot-starter</artifactId>
</dependency>
推荐阅读
- parallel-processing - 如何为 cuda 并行编程提供输入文件?
- python-3.x - Divide data into bins with inf Python
- angular - 如何在 Firebase 实时数据库(Angular)中仅获取()多个更新值
- google-apps-script - 如何保持值 1 并在每次看到时加 1?
- laravel - 找不到图片来源
- excel - 带有条件“或”的 Excel VlookUp 函数
- apache-spark - 如何检查 reduceByKey 在 spark-streaming 中是否有效执行
- angular - 在 Angular 7 应用程序中使用 svg.js 插件时出现 Prod 构建错误
- android - 尝试将位置坐标从列表视图传递到地图活动时出错
- angular - 使用打字稿模型类时将条件替换为多态