bug日记#2
Could not find artifact org.springframework.cloud:spring-cloud-starter-consul-discovery:pom:unknown in nexus-aliyun (http://maven.aliyun.com/nexus/content/groups/public)
报错截图:
解决方法:
‘dependencies.dependency.version’ for org.springframework.cloud:spring-cloud-starter-consul-discovery:jar is missing.
报错原因显示没有加依赖版本
加入以下代码解决报错
<!--spring cloud-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
原因
在Maven中dependencyManagement的作用其实相当于一个对所依赖jar包进行版本管理的管理器。
如果dependencies里的dependency自己没有声明version元素,那么maven就会到dependencyManagement里面去找有没有对该artifactId和groupId进行过版本声明,如果有,就继承它,如果没有就会报错,告诉你必须为dependency声明一个version