• [ERROR] Error creating bean with name 'aliCloudEdasSdk' defined in class path resource


    环境

    spring-cloud-alibaba-dependencies 2021.0.1.0

    gulimall-common pom.xml

    <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>aliyun-oss-spring-boot-starter</artifactId>
    </dependency>
    
    ....
    
    <dependencyManagement>
    	<dependenies>
    		<dependency>
          <groupId>com.alibaba.cloud</groupId>
          <artifactId>aliyun-spring-boot-dependencies</artifactId>
          <version>1.0.0</version>
          <type>pom</type>
          <scope>import</scope>
         </dependency>
      </dependencies>
    </dependencyManagement>
    

    gulimall-product pom.xml

            <dependency>
                <groupId>com.atguigu.gulimall</groupId>
                <artifactId>gulimall-common</artifactId>
                <version>0.0.1-SNAPSHOT</version>
            </dependency>
    

    错误提示

    2022-04-18 21:15:08.104  WARN 79340 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aliCloudEdasSdk' defined in class path resource [com/alibaba/cloud/spring/boot/context/autoconfigure/EdasContextAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alibaba.cloud.context.edas.AliCloudEdasSdk]: Factory method 'aliCloudEdasSdk' threw exception; nested exception is java.lang.NoSuchMethodError: com.aliyuncs.profile.DefaultProfile.getHttpClientConfig()Lcom/aliyuncs/http/HttpClientConfig;
    
    
    ***************************
    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.<init>(AliCloudSdk.java:76)
    
    The following method did not exist:
    
        com.aliyuncs.profile.DefaultProfile.getHttpClientConfig()Lcom/aliyuncs/http/HttpClientConfig;
    
    The calling method's class, com.alibaba.cloud.context.AliCloudSdk, was loaded from the following location:
    
        jar:file:/Users/xiaoming/local/.m2/repository/com/alibaba/cloud/alicloud-context/1.0.5/alicloud-context-1.0.5.jar!/com/alibaba/cloud/context/AliCloudSdk.class
    
    The called method's class, com.aliyuncs.profile.DefaultProfile, is available from the following locations:
    
        jar:file:/Users/xiaoming/local/.m2/repository/com/aliyun/aliyun-java-sdk-core/3.4.0/aliyun-java-sdk-core-3.4.0.jar!/com/aliyuncs/profile/DefaultProfile.class
    
    The called method's class hierarchy was loaded from the following locations:
    
        com.aliyuncs.profile.DefaultProfile: file:/Users/xiaoming/local/.m2/repository/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 compatible versions of the classes com.alibaba.cloud.context.AliCloudSdk and com.aliyuncs.profile.DefaultProfile
    
    

    根据提示是因为 aliyun-java-sdk-core-3.4.0.jar 这个包没有指定的方法

    通过查看idea 查看 maven depenencies 依赖图发现 aliyun-java-sdk-core 并没有爆红显示冲突,
    不过我们将鼠标放在 aliyun-java-sdk-core 看到版本显示为 4.5.0,而点进去看到的版本却是3.4.0。
    说明 aliyun-oss-spring-boot-starter 中引入的是3.4.0版本,那么这个4.5.0版本在哪里呢?
    在 aliyun-spring-boot-dependencies 依赖管理组件中发现引入的是4.5.0

    解决办法

    上面已经找到冲突的包
    那么只需要排除3.4.0 即可 (可不单独再引入 4.5.0)

            <!-- 阿里云 oss -->
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>aliyun-oss-spring-boot-starter</artifactId>
                <exclusions>
                    <exclusion>
                        <groupId>com.aliyun</groupId>
                        <artifactId>aliyun-java-sdk-core</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    
  • 相关阅读:
    HDU1542 Atlantis(矩形面积并)
    HDU4784 Dinner Coming Soon(dp)
    1023: [SHOI2008]cactus仙人掌图(DP+单调队列优化)
    BZOJ 1004: [HNOI2008]Cards(群论)
    BZOJ USACO 银组 水题集锦
    BZOJ 3401: [Usaco2009 Mar]Look Up 仰望(离线+平衡树)
    BZOJ 3404: [Usaco2009 Open]Cow Digit Game又见数字游戏(博弈论)
    BZOJ 3208: 花神的秒题计划Ⅰ
    BZOJ 2456: mode(乱搞)
    BZOJ 2424: [HAOI2010]订货(费用流)
  • 原文地址:https://www.cnblogs.com/52liming/p/16163035.html
Copyright © 2020-2023  润新知