Maven:项目构建错误“modelVersion”丢失

问题描述 投票:0回答:3

我正在尝试创建一个新的 Maven 项目,但我从 pom.xml 中收到此错误...

有人可以帮我解决这个问题吗?我是 Maven 和 Eclipse IDE 的新手

非常感谢。

Error details

java eclipse maven
3个回答
7
投票

您的

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 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>your.group.id</groupId>
    <artifactId>your-artifact-id</artifactId>
    <version>your-version</version>

<!-- all stuff here -->

</project>

0
投票

这是到目前为止 POM.XML 文件的 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 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>maven-examples</artifactId>
    <groupId>com.infiniteskills.maven</groupId>
    <version>1.0.0</version>
    
    <packaging>jar</packaging>
    <name>Learning Maven Examples</name>
    <description>This is a project used to demonstrate maven principles</description>
    <url>http://course.maven.infiniteskills.com</url>
    
    <licenses>
        <license>
            <name>Apache License</name>
            <comments>We are pretty good about sharing</comments>
        </license>
    </licenses>
    
    <organization>
        <name>Infinite Skills</name>
        <url>http:/www.infiniteskills.com</url>
    </organization>
    
    <developers>
        <developer>
            <name>Kevin Bowersox</name>
            <email>[email protected]</email>
        </developer>
        <developer>
            <name>MR.Abdullah AbdulMajeed</name>
            <email>[email protected]</email>
        </developer>
    </developers>
</project>

-1
投票

我也遇到同样的问题..

我尝试附加相同的样式,并向我显示了一堆错误消息,如下所示:

[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'modelVersion' is missing. @ line 2, column 206
[FATAL] 'groupId' is missing. @ line 2, column 206
[FATAL] 'artifactId' is missing. @ line 2, column 206
[FATAL] 'version' is missing. @ line 2, column 206
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project [unknown-group-id]:[unknown-artifact-id]:[unknown-version] (C:\Users\Abo Zahra\eclipse-workspace\maven-examples\pom.xml) has 4 errors     
[ERROR]     'modelVersion' is missing. @ line 2, column 206
[ERROR]     'groupId' is missing. @ line 2, column 206
[ERROR]     'artifactId' is missing. @ line 2, column 206
[ERROR]     'version' is missing. @ line 2, column 206
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

我想我们正在遵循相同的教程,链接: https://www.youtube.com/watch?v=uAQs-YXnY-U&t=458s&ab_channel=DevLessons

任何帮助将不胜感激,提前致谢

© www.soinside.com 2019 - 2024. All rights reserved.