maven常見錯誤

  1. 錯誤如下: ‘packaging’ with value ‘’ is invalid. Aggregator projects require ‘pom’ as packaging. @ line 11, column 16
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unknown packaging:  @ line 11, column 16
[ERROR] 'packaging' is missing. @ line 11, column 16
[ERROR] 'packaging' with value '' is invalid. Aggregator projects require 'pom' as packaging. @ line 11, column 16
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.atguigu.springcloud:microsevicecloud:0.0.1-SNAPSHOT (/Users/wyshown/Study/microsevicecloud/pom.xml) has 3 errors
[ERROR]     Unknown packaging:  @ line 11, column 16
[ERROR]     'packaging' is missing. @ line 11, column 16
[ERROR]     'packaging' with value '' is invalid. Aggregator projects require 'pom' as packaging. @ line 11, column 16
[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

代碼如下:

<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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <!--GroupID 是項目組織的唯一標識符,在實際開發中對應JAVA的包的結構,就是main目錄裏java的目錄結構,如 ‘com.atguigu.test’。-->
    <groupId>com.atguigu.springcloud</groupId>
    <!--ArtifactID就是項目的唯一標識符,在實際開發中一般對應項目的名稱,就是項目根目錄的名稱。-->
    <artifactId>microsevicecloud</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
</project>

原因如下:
因爲maven工程, 當不設置packaging指定參數的話, packaging的默認值爲jar, 而pom的父類工程不能爲jar, 所有會出此錯誤
解決方法,
查看父類的pom文件 是否有pom 如果無則添加pom

2.Non-resolvable parent POM for com.atguigu.springcloud:microsevicecloud-api:1.0-SNAPSHOT: Could not find artifact com.atguigu.springcloud:microsevicecloud:pom:0.0.1-SNAPSHOT and ‘parent.relativePath’ points at wrong local POM @ line 8, column 13

[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.atguigu.springcloud:microsevicecloud-api:1.0-SNAPSHOT: Could not find artifact com.atguigu.springcloud:microsevicecloud:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 8, column 13
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.atguigu.springcloud:microsevicecloud-api:1.0-SNAPSHOT (/Users/wyshown/Study/microsevicecloud-api/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for com.atguigu.springcloud:microsevicecloud-api:1.0-SNAPSHOT: Could not find artifact com.atguigu.springcloud:microsevicecloud:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 8, column 13 -> [Help 2]
[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
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

Process finished with exit code 1

代碼如下:

<parent>
    <!--GroupID 是項目組織的唯一標識符,在實際開發中對應JAVA的包的結構,就是main目錄裏java的目錄結構,如 ‘com.atguigu.test’。-->
    <groupId>com.atguigu.springcloud</groupId>
    <!--ArtifactID就是項目的唯一標識符,在實際開發中一般對應項目的名稱,就是項目根目錄的名稱。-->
    <artifactId>microsevicecloud</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>

更改後如下:

<parent>
    <!--GroupID 是項目組織的唯一標識符,在實際開發中對應JAVA的包的結構,就是main目錄裏java的目錄結構,如 ‘com.atguigu.test’。-->
    <groupId>com.atguigu.springcloud</groupId>
    <!--ArtifactID就是項目的唯一標識符,在實際開發中一般對應項目的名稱,就是項目根目錄的名稱。-->
    <artifactId>microsevicecloud</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>../microsevicecloud/pom.xml</relativePath>
</parent>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章