<dependency>
<groupId>***.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
项目中pom.xml直接用这个maven会报Could not find artifact ***.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery:pom:unknown in aliyun-public (https://maven.aliyun.***/repository/public)
试了几种方法包括:
- 指定版本为1.4.1
- 在.m2/settings.xml里添加新的阿里云源
- Invalid cache重启
- maven clean
发现都没用。最终解决方法是在pom的dependencyManagement添加
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>***.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring-cloud-alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
${spring-cloud-alibaba.version} 要根据对应的springboot版本来选。详见springcloud alibaba 版本说明