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

前言

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.(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

<dependency>
    <groupId>com.alibaba.cloudgroupId>
    <artifactId>aliyun-oss-spring-boot-starterartifactId>
    <version>1.0.0version>
dependency>

2. 当引入后,启动程序发现报如上错误信息,大概意思就是 aliyun-java-sdk-core jar包 版本与SpringBoot 版本不兼容

解决

1. 最后在 阿里云的maven仓库找到了个aliyun-java-sdk-core 高版本的依赖导入。

2.pom文件如下

		
        <dependency>
            <groupId>com.alibaba.cloudgroupId>
            <artifactId>aliyun-oss-spring-boot-starterartifactId>
            <version>1.0.0version>
        dependency>
        
		<dependency>
            <groupId>com.aliyungroupId>
            <artifactId>aliyun-java-sdk-coreartifactId>
            <version>4.4.5version>
        dependency>

一个在码农道路上孤独行走的人

微信搜索【Java猿记】

你可能感兴趣的:(BUG记录总结,bug)