转载自: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
复制代码
经过
- 在项目整合阿里云OSS时,使用了官网 GitHub 上的示例,进行整合,就是直接在pom 文件中引入对应的starter
com.alibaba.cloud
aliyun-oss-spring-boot-starter
1.0.0
复制代码 - 当引入后,启动程序发现报如上错误信息,大概意思就是 aliyun-java-sdk-core jar包 版本与SpringBoot 版本不兼容
解决 - 最后在 阿里云的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
来源:稀土掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。