我的任务是获取 aws procuct 定价数据,所以我执行以下操作:
设置环境变量(AWS_ACCESS_KEY_ID 和 AWS_SECRET_ACCESS_KEY)
用代码填充 pom.xml(在 Eclipse 中):
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-pricing</artifactId>
<version>1.11.513</version>
</dependency>
- 然后我像代码一样编写测试方法:
public static void testDescribeServices() {
System.out.println("\n\n begin ....");
AWSPricing client = AWSPricingClientBuilder.standard().withRegion("us-east-1").build();
System.out.println("step 0001");
DescribeServicesRequest servicesRequest = new DescribeServicesRequest();
servicesRequest.setServiceCode("AmazonEC2");
DescribeServicesResult result = client.describeServices(servicesRequest);
List<Service> serviceList = result.getServices();
}
- 运行 testDescribeServices() 方法,控制台上的消息是这样的:(我很失望)
begin ....
17:08:21.166 [main] DEBUG com.amazonaws.AmazonWebServiceClient - Internal logging successfully configured to commons logger: true
17:08:21.831 [main] DEBUG com.amazonaws.monitoring.CsmConfigurationProviderChain - Unable to load configuration from com.amazonaws.monitoring.EnvironmentVariableCsmConfigurationProvider@130d63be: Unable to load Client Side Monitoring configurations from environment variables!
17:08:21.831 [main] DEBUG com.amazonaws.monitoring.CsmConfigurationProviderChain - Unable to load configuration from com.amazonaws.monitoring.SystemPropertyCsmConfigurationProvider@42a48628: Unable to load Client Side Monitoring configurations from system properties variables!
17:08:21.831 [java-sdk-http-connection-reaper] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Closing connections idle longer than 60000 MILLISECONDS
17:08:21.839 [main] DEBUG com.amazonaws.monitoring.CsmConfigurationProviderChain - Unable to load configuration from com.amazonaws.monitoring.ProfileCsmConfigurationProvider@689604d9: The 'default' profile does not define all the required properties!
Exception in thread "main" java.lang.NoSuchMethodError: com.amazonaws.client.AwsSyncClientParams.getAdvancedConfig()Lcom/amazonaws/client/builder/AdvancedConfig;
at com.amazonaws.services.pricing.AWSPricingClient.<init>(AWSPricingClient.java:158)
at com.amazonaws.services.pricing.AWSPricingClient.<init>(AWSPricingClient.java:142)
at com.amazonaws.services.pricing.AWSPricingClientBuilder.build(AWSPricingClientBuilder.java:61)
at com.amazonaws.services.pricing.AWSPricingClientBuilder.build(AWSPricingClientBuilder.java:27)
at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
at com.yunion.apps.metadata.TestAWSDemoAPI.testDescribeServices(TestAWSDemoAPI.java:31)
at com.yunion.apps.metadata.TestAWSDemoAPI.main(TestAWSDemoAPI.java:26)