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