整合OSS依赖导入后启动报错

转载自:https://juejin.cn/post/6921255454807392269
前言
SpringBoot 2.3.3 版本整合OSS,将依赖导入后启动报错。

错误信息如下:
APPLICATION FAILED TO START
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.alibaba.cloud.context.AliCloudSdk.(AliCloudSdk.java:76)…
Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

com.alibaba.cloud.context.AliCloudSdk.<init>(AliCloudSdk.java:76)

The following method did not exist:

com.aliyuncs.profile.DefaultProfile.getHttpClientConfig()Lcom/aliyuncs/http/HttpClientConfig;

The method’s class, com.aliyuncs.profile.DefaultProfile, is available from the following locations:

jar:file:/D:/Tools/maven/com/aliyun/aliyun-java-sdk-core/3.4.0/aliyun-java-sdk-core-3.4.0.jar!/com/aliyuncs/profile/DefaultProfile.class

The class hierarchy was loaded from the following locations:

com.aliyuncs.profile.DefaultProfile: file:/D:/Tools/maven/com/aliyun/aliyun-java-sdk-core/3.4.0/aliyun-java-sdk-core-3.4.0.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of com.aliyuncs.profile.DefaultProfile

复制代码
经过

  1. 在项目整合阿里云OSS时,使用了官网 GitHub 上的示例,进行整合,就是直接在pom 文件中引入对应的starter

    com.alibaba.cloud
    aliyun-oss-spring-boot-starter
    1.0.0

    复制代码
  2. 当引入后,启动程序发现报如上错误信息,大概意思就是 aliyun-java-sdk-core jar包 版本与SpringBoot 版本不兼容
    解决
  3. 最后在 阿里云的maven仓库找到了个aliyun-java-sdk-core 高版本的依赖导入。
    2.pom文件如下


    com.alibaba.cloud
    aliyun-oss-spring-boot-starter
    1.0.0



    com.aliyun
    aliyun-java-sdk-core
    4.4.5

    复制代码

一个在码农道路上孤独行走的人
微信搜索【Java猿记】

作者:Java猿记
链接:https://juejin.cn/post/6921255454807392269
来源:稀土掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值