前言
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)……
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| 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
1 2 3 4 5
| <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>aliyun-oss-spring-boot-starter</artifactId> <version>1.0.0</version> </dependency>
|
2. 当引入后,启动程序发现报如上错误信息,大概意思就是 ==aliyun-java-sdk-core== jar包 版本与SpringBoot 版本不兼容
解决
1. 最后在 阿里云的maven仓库找到了个==aliyun-java-sdk-core== 高版本的依赖导入。
2.pom文件如下
1 2 3 4 5 6 7 8 9 10 11 12
| <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>aliyun-oss-spring-boot-starter</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-core</artifactId> <version>4.4.5</version> </dependency>
|
一个在码农道路上孤独行走的人
微信搜索【Java猿记】