Maven異常:0.0.1-SNAPSHOT: Could not find artifact

解決方案

將父項目install到本地倉庫,重新對子項目進行打包

報錯情景

父項目需要用到子項目,會將子項目加入POM的依賴
比如:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.tonited</groupId>
            <artifactId>hello-spring-cloud-alibaba-dependencies</artifactId>
            <version>${project.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

子項目打包時會報錯
比如:

The build could not read 1 project -> [Help 1]
The project com.tonited:hello-spring-cloud-alibaba-provider:0.0.1-SNAPSHOT (C:\Users\Tonited\Desktop\hello-spring-cloud-alibaba\hello-spring-cloud-alibaba-provider\pom.xml) has 3 errors
Non-resolvable import POM: Could not find artifact com.tonited:hello-spring-cloud-alibaba-dependencies:pom:0.0.1-SNAPSHOT in aliyunmaven (https://maven.aliyun.com/nexus/content/groups/public) @ com.tonited:hello-spring-cloud-alibaba:0.0.1-SNAPSHOT, C:\Users\Tonited\Desktop\hello-spring-cloud-alibaba\pom.xml, line 43, column 25 -> [Help 2]
‘dependencies.dependency.version’ for org.springframework.cloud:spring-cloud-starter-alibaba-nacos-discovery:jar is missing. @ line 45, column 21
‘dependencies.dependency.version’ for org.springframework.cloud:spring-cloud-starter-alibaba-nacos-config:jar is missing. @ line 50, column 21
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

原因

其實是因爲子項目打包需要依賴父項目,但是在檢查本地倉庫時發現倉庫中並沒有父項目,於是就會去倉庫找
倉庫當然沒有你的父項目,就會報錯

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章