cvc-elt.1.a: 找不到元素 'project' 的声明
cvc-elt.1.a: Cannot find the declaration of element 'project'
错误:cvc-elt.1.a:找不到元素 'project'
的声明
我经常收到这个错误。每当我使用 Maven 创建项目时,它都会开始显示此错误。我什至提到了插件标签下的'maven-war-plugin',然后也更新和刷新了项目。
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myfirstmvcapp</groupId>
<artifactId>helloworldabc</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>helloworldabc Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
</plugins>
<finalName>helloworldabc</finalName>
</build>
</project>
我找到了这个问题的解决方案,感谢@M.Deinum在问题下方评论了解决方案。
我所做的只是将 https 添加到标签中的 link,而不是 http。
这是之前的代码:
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myfirstmvcapp</groupId>
<artifactId>helloworldabc</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>helloworldabc Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
</plugins>
<finalName>helloworldabc</finalName>
</build>
</project>
这是最新的代码,只需要在项目标签的最后link中的xsd link中添加https而不是http。
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myfirstmvcapp</groupId>
<artifactId>helloworldabc</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>helloworldabc Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
</plugins>
<finalName>helloworldabc</finalName>
</build>
</project>
我必须对所有这些都使用 https,即
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
让 VSCode 中的警告消失。
错误:cvc-elt.1.a:找不到元素 'project'
的声明我经常收到这个错误。每当我使用 Maven 创建项目时,它都会开始显示此错误。我什至提到了插件标签下的'maven-war-plugin',然后也更新和刷新了项目。
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myfirstmvcapp</groupId>
<artifactId>helloworldabc</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>helloworldabc Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
</plugins>
<finalName>helloworldabc</finalName>
</build>
</project>
我找到了这个问题的解决方案,感谢@M.Deinum在问题下方评论了解决方案。
我所做的只是将 https 添加到标签中的 link,而不是 http。
这是之前的代码:
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myfirstmvcapp</groupId>
<artifactId>helloworldabc</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>helloworldabc Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
</plugins>
<finalName>helloworldabc</finalName>
</build>
</project>
这是最新的代码,只需要在项目标签的最后link中的xsd link中添加https而不是http。
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myfirstmvcapp</groupId>
<artifactId>helloworldabc</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>helloworldabc Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
</plugin>
</plugins>
<finalName>helloworldabc</finalName>
</build>
</project>
我必须对所有这些都使用 https,即
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
让 VSCode 中的警告消失。