在我的IntelliJ IDE中的project 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>我怎么才能解决这个问题?
发布于 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”部分中指定的那样。
<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“部分中指定的部署描述符根声明。
<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">另请参阅:
https://stackoverflow.com/questions/72403159
复制相似问题