alibaba / aliyun-spring-boot

Spring Boot Starters for Aliyun services
Apache License 2.0
451 stars 109 forks source link

[Question] throw a error #51

Open yxh-flow opened 3 years ago

yxh-flow commented 3 years ago

image Caused by: 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;

my code:

@RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = {ThirdPartyApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) public class ThirdPartyApplicationTests {

@Autowired
private OSS ossClient;

@Test
public void  testUpdload(){

    String bucketName = "yangxiaohui";

    String objectName = "product/b.json";

    String content = "{name:yangxiaohui}";
    ossClient.putObject(bucketName, objectName, new ByteArrayInputStream(content.getBytes()));
    ossClient.shutdown();
}

}

yxh-flow commented 3 years ago

maven : dependency>

com.alibaba.cloud
        <artifactId>aliyun-oss-spring-boot-starter</artifactId>
        <version>1.0.0</version>
    </dependency>

and I have configured the relevant properties in my application.yml ;such as access-key,secret-key,endpoint

ppzzyy11 commented 3 years ago

Can you upload your project to a github repository so I can help you figure out conflicts.

Sunnypain commented 2 years ago

you can import another dependency which like this to solve your problem:

com.aliyun aliyun-java-sdk-core 4.5.0
Surrin1999 commented 2 years ago

you can import another dependency which like this to solve your problem: com.aliyun aliyun-java-sdk-core 4.5.0

Thank you