【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即可成功