首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >元素faces-config必须声明。

元素faces-config必须声明。
EN

Stack Overflow用户
提问于 2022-05-27 09:18:26
回答 1查看 260关注 0票数 1

在我的IntelliJ IDE中的project config.xml文件中出现了这个错误:

元素faces-config必须声明。

下面是我的faces-config.xml文件:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
        xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
        http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_3_0.xsd"
        version="2.3">
    
</faces-config>

和pom.xml文件:

代码语言:javascript
复制
<?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>

    ...

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.target>17</maven.compiler.target>
        <maven.compiler.source>17</maven.compiler.source>
    </properties>

    <dependencies>
        <dependency>
            <groupId>jakarta.platform</groupId>
            <artifactId>jakarta.jakartaee-api</artifactId>
            <version>9.1.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.3.2</version>
            </plugin>
        </plugins>
    </build>
</project>

我怎么才能解决这个问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-27 10:03:01

xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 0.xsd

尝试在您最喜欢的网页浏览器中打开0.xsd。它返回404。换句话说,这个URL是不正确的。IDE内置的XML解析器也在以这种方式挣扎。它在那里找不到<faces-config>根元素的声明。

目前还不清楚您打算使用哪个JSF版本进行开发。如果如version="2.3"所示,它是2.3,那么您应该使用3.xsd,就像http://xmlns.jcp.org/xml/ns/javaee后面的网页“JavaEE8SchemaResources”部分中指定的那样。

代码语言:javascript
复制
<faces-config
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
        http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"
    version="2.3">

但是,如果它确实是3.0,那么您应该使用Jakarta的第一个jakarta.*包,而不是javax.*包),那么您应该使用https://jakarta.ee/xml/ns/jakartaee后面网页的"Jakarta 9“部分中指定的部署描述符根声明。

代码语言:javascript
复制
<faces-config
    xmlns="https://jakarta.ee/xml/ns/jakartaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
        https://jakarta.ee/xml/ns/jakartaee/web-facesconfig_3_0.xsd"
    version="3.0">

另请参阅:

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72403159

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档