Mus*_*aul 27 java xml spring spring-mvc maven
错误: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>
Run Code Online (Sandbox Code Playgroud)
Mus*_*aul 36
我已经找到了这个问题的解决方案,感谢@M.Deinum,他在问题下面评论了解决方案。
我所做的只是将 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 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>
Run Code Online (Sandbox Code Playgroud)
这是最新的代码,所需要做的就是将 https 而不是 http 添加到项目标签最后一个链接中的 xsd 链接中。
<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>
Run Code Online (Sandbox Code Playgroud)
R..*_*... 16
我必须对所有这些都使用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">
Run Code Online (Sandbox Code Playgroud)
让警告在 VSCode 中消失。
小智 6
由于在 Eclipse IDE for Enterprise Java and Web Developers Version: 2023-09 (4.29.0) 中不存在将 http 替换为 https 以及使用 Java version: 17.0.8.1 等问题
需要强制下载 https://maven.apache.org/xsd/maven-4.0.0.xsd;只需将鼠标悬停在此链接上并单击下载即可。
| 归档时间: |
|
| 查看次数: |
66681 次 |
| 最近记录: |