在创建AmazonSNS的Bean时获取异常

时间:2018-10-06 17:14:35

标签: java amazon-web-services amazon-ec2 aws-sdk aws-java-sdk

我想将aws-java-sdk版本更新为1.11.335,但是在创建 AmazonSNS

的Bean时遇到异常

Bean创建代码:

@Bean(name = "amazonSnsClient")
    public AmazonSNS amazonSNSClient() {
        AmazonSNS snsClient = AmazonSNSClient.builder().withRegion(Regions.fromName(snsConfig.getRegion())).build();
        return snsClient;
    }

使用课程

 @Autowired
    @Qualifier("amazonSnsClient")
    private AmazonSNS snsClient;

在pom.xml中

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk</artifactId>
    <version>1.11.335</version>
</dependency>
<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.2</version>
    <scope>runtime</scope>
</dependency>

获得例外

Caused by: java.lang.NoClassDefFoundError: org/apache/http/conn/ConnectionKeepAliveStrategy
    at com.amazonaws.http.AmazonHttpClient.<clinit>(AmazonHttpClient.java:149) ~[Server.jar:na]
    at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:175) ~[Server.jar:na]
    at com.amazonaws.services.sns.AmazonSNSClient.<init>(AmazonSNSClient.java:251) ~[Server.jar:na]
    at com.amazonaws.services.sns.AmazonSNSClientBuilder.build(AmazonSNSClientBuilder.java:60) ~[Server.jar:na]
    at com.amazonaws.services.sns.AmazonSNSClientBuilder.build(AmazonSNSClientBuilder.java:26) ~[Server.jar:na]
    at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46) ~[Server.jar:na]

0 个答案:

没有答案