使用阿里云oss报错:com.alibaba.cloud:aliyun-oss-spring-boot-starter:jar:unknown was not found in
根据阿里云OSS的案例文档,在springboot项目中配置pom 时报错
https://github.com/alibaba/aliyun-spring-boot/tree/master/aliyun-spring-boot-samples/aliyun-oss-spring-boot-sample
demo中的配置:
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>aliyun-oss-spring-boot-starter</artifactId> </dependency>
完整报错信息:
com.alibaba.cloud:aliyun-oss-spring-boot-starter:jar:unknown was not found in https://maven.aliyun.com/nexus/content/repositories/central/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of alimaven has elapsed or updates are forced
尝试使用 -U 标记(强制更新快照)运行 Maven 导入
解决方法:
在 https://mvnrepository.com/ 中搜索到 aliyun-oss 的配置,需要加上版本号1.0.0 就可以成功导入,这个版本的维护到2020年
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>aliyun-oss-spring-boot-starter</artifactId> <version>1.0.0</version> </dependency>
上面方法解决了pom导入报错问题,但是使用官方的配置方法仍然报错
// application.properties alibaba.cloud.access-key=your-ak alibaba.cloud.secret-key=your-sk alibaba.cloud.oss.endpoint=***
最终使用:
pom.xml中配置
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alicloud-oss</artifactId> <version>2.2.0.RELEASE</version> </dependency>
application.yml中配置
spring: cloud: alicloud: access-key: your-ak secret-key: your-sk oss: endpoint: ***