【maven】本地項目依賴打jar包失敗 Could not resolve dependencies for project
#記錄一下今天遇到的一個maven的打包問題
由於使用spring cloud 的微服務架構,故而有些項目的類需要公用,便想用單獨的公共項目進行引用出現如下問題
1.使用Eclipse -Run -Maven builder 進行打包出現如下錯誤
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< com.ysservice:eureka-server-backup >-----------------
[INFO] Building eureka-server-backup 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/cn/com/ysservice/yongsheng-common/1.0/yongsheng-common-1.0.pom
[WARNING] The POM for cn.com.ysservice:yongsheng-common:jar:1.0 is missing, no dependency information available
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/cn/com/ysservice/yongsheng-common/1.0/yongsheng-common-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.269 s
[INFO] Finished at: 2018-09-28T17:37:12+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project eureka-server-backup: Could not resolve dependencies for project com.ysservice:eureka-server-backup:jar:0.0.1-SNAPSHOT: Could not find artifact cn.com.ysservice:yongsheng-common:jar:1.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
[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/DependencyResolutionException
從報錯情況來看,應該是maven下載不到依賴的包
本人依賴如下
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 項目依賴 這是本地項目-->
<dependency>
<groupId>cn.com.ysservice</groupId>
<artifactId>yongsheng-common</artifactId>
<version>1.0</version>
</dependency>
於是想,應該是下載不到jar包,那麼解決辦法如下:
- 先將該項目 yongsheng-common 打成jar包
- 然後再講本項目進行package即可成功