Error on integrating Primefaces with Springboot/JoinFaces

寵の児 提交于 2021-01-28 17:43:39

问题


I´m trying to create an application that integrates primefaces with spring boot following these tutorials:

https://medium.com/@tsepomaleka/integrating-spring-boot-with-java-server-faces-using-joinfaces-297e64f6a28f

https://codenotfound.com/jsf-primefaces-example.html

And i added the joinfaces as the tutorial suggests:

This is my 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>

And i created the webapp/WEB-INF folder structure:

As you can see on the image the webapp folder doesn't look like that is recognized by intellij.

Other problem is that the xmlns:p="http://primefaces.org/ui" url taglib is not being recognized as you can see on the image.

So when i run on the browser: http://localhost:8080/eleicao.xhtml The browser returns me an error:

There was an unexpected error (type=Not Found, status=404). /eleicao.xhtml Not Found in ExternalContext as a Resource

So how can i resolve this? So that i can run primefaces pages.


回答1:


You are missing a bunch of depenedencies here is my pom for PrimeFaces, MyFaces for JSF, OmniFaces, and Undertow as the servlet engine

        <!-- 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>


来源:https://stackoverflow.com/questions/61093213/error-on-integrating-primefaces-with-springboot-joinfaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!