必须声明元素面孔
我在project faces-config.xml 文件中有一个错误:
必须声明元素faces-config
这是我的faces-config.xml文件:
<?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文件:
<?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>
如何解决此问题?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试打开 http://xmlns.jcp.org/xml/xml/ns/ javaee/web-facesconfig_3_0.xsd 在您喜欢的WebBrowser中。它返回404。换句话说,此URL不正确。 IDE的内置XML解析器也在这种方式挣扎。它找不到
&lt; faces-config&gt;
root Element的声明。目前尚不清楚您打算使用哪种JSF版本。如果是2.3,如
版本=“ 2.3”
所示,则应使用 http://xmlns.jcp.org/xml/xml/ns/javaee/javaee/web-facesconfig_2_2_33.xsd 相反,如在“ Java Ee 8架构资源”部分中指定的WebPage在但是,如果确实是3.0,则第一个jakartified版本(即,您应该在所有位置使用
jakarta。您应该使用以下部署描述符root声明,如。
另请参阅:
Try opening http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_3_0.xsd in your favorite webbrowser. It returns 404. In other words, this URL is not correct. The IDE's built-in XML parser is also struggling this way. It cannot find the declaration of
<faces-config>
root element there.It's not clear which JSF version exactly you intend to develop with. If it's 2.3, as indicated by
version="2.3"
, then you should be using http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd instead, as specified in "Java EE 8 Schema Resources" section of the webpage behind http://xmlns.jcp.org/xml/ns/javaee.But if it's indeed 3.0, the first Jakartified version (i.e. you should be using
jakarta.*
package for Jakarta EE API over all place instead ofjavax.*
package), then you should be using the following deployment descriptor root declaration as specified in "Jakarta EE 9" section of the webpage behind https://jakarta.ee/xml/ns/jakartaee.See also: