Amazon dynamo db java客户端-NoSuchMethodError
尝试使用以下代码运行本地amazon dynamo db客户机,这基本上只是我在线获得的一个示例,我创建了带有本地堆栈的表,因此它应该存在,但我不确定问题出在哪里Amazon dynamo db java客户端-NoSuchMethodError,java,amazon-web-services,sdk,amazon-dynamodb,Java,Amazon Web Services,Sdk,Amazon Dynamodb,尝试使用以下代码运行本地amazon dynamo db客户机,这基本上只是我在线获得的一个示例,我创建了带有本地堆栈的表,因此它应该存在,但我不确定问题出在哪里 public static void main(String[] args) { AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().build(); DynamoDB dynamoDB = new DynamoDB(c
public static void main(String[] args) {
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().build();
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("attestation-db");
// Build a list of related items
List<Number> relatedItems = new ArrayList<Number>();
relatedItems.add(341);
relatedItems.add(472);
relatedItems.add(649);
//Build a map of product pictures
Map<String, String> pictures = new HashMap<String, String>();
pictures.put("FrontView", "http://example.com/products/123_front.jpg");
pictures.put("RearView", "http://example.com/products/123_rear.jpg");
pictures.put("SideView", "http://example.com/products/123_left_side.jpg");
//Build a map of product reviews
Map<String, List<String>> reviews = new HashMap<String, List<String>>();
List<String> fiveStarReviews = new ArrayList<String>();
fiveStarReviews.add("Excellent! Can't recommend it highly enough! Buy it!");
fiveStarReviews.add("Do yourself a favor and buy this");
reviews.put("FiveStar", fiveStarReviews);
List<String> oneStarReviews = new ArrayList<String>();
oneStarReviews.add("Terrible product! Do not buy this.");
reviews.put("OneStar", oneStarReviews);
// Build the item
Item item = new Item()
.withPrimaryKey("Id", 123)
.withString("Title", "Bicycle 123")
.withString("Description", "123 description")
.withString("BicycleType", "Hybrid")
.withString("Brand", "Brand-Company C")
.withNumber("Price", 500)
.withStringSet("Color", new HashSet<String>(Arrays.asList("Red", "Black")))
.withString("ProductCategory", "Bicycle")
.withBoolean("InStock", true)
.withNull("QuantityOnHand")
.withList("RelatedItems", relatedItems)
.withMap("Pictures", pictures)
.withMap("Reviews", reviews);
// Write the item to the table
PutItemOutcome outcome = table.putItem(item);
publicstaticvoidmain(字符串[]args){
AmazonDynamoDB client=AmazonDynamoDBClientBuilder.standard().build();
DynamoDB DynamoDB=新DynamoDB(客户);
Table=dynamoDB.getTable(“认证数据库”);
//建立相关项目的列表
List relatedItems=新建ArrayList();
相关项目。增加(341);
相关项目。增加(472);
相关项目。增加(649);
//建立一个产品图片地图
Map pictures=新的HashMap();
图片。放置(“FrontView”http://example.com/products/123_front.jpg");
图片。放置(“后视图”http://example.com/products/123_rear.jpg");
图片。放置(“侧视图”http://example.com/products/123_left_side.jpg");
//建立产品评论地图
Map reviews=newhashmap();
List FiveStarrViews=新建ArrayList();
FiveStarrViews.add(“太棒了!推荐得不够高!买吧!”);
添加(“帮你自己一个忙,买这个”);
评论。发表(“FiveStar”,FivestarView);
List oneStarReviews=newarraylist();
添加(“糟糕的产品!不要买这个。”);
评论。发布(“OneStar”,OneStarEviews);
//构建项目
项目=新项目()
.withPrimaryKey(“Id”,123)
.带字符串(“标题”,“自行车123”)
.带字符串(“说明”、“123说明”)
.withString(“BicycleType”、“Hybrid”)
.withString(“品牌”、“品牌公司C”)
.带编号(“价格”,500)
.with字符串集(“颜色”,新哈希集(Arrays.asList(“红色”,“黑色”))
.with字符串(“产品类别”、“自行车”)
.withBoolean(“InStock”,true)
.withNull(“现有数量”)
.withList(“相关项目”,相关项目)
.withMap(“图片”,图片)
.withMap(“评论”,评论);
//将项目写入表中
putItem结果=表。putItem(项目);
但是,当我运行main方法时,我不断得到以下错误
Exception in thread "main" java.lang.NoSuchMethodError: com.amazonaws.util.StringUtils.trim(Ljava/lang/String;)Ljava/lang/String;
at com.amazonaws.auth.profile.internal.AwsProfileNameLoader.getEnvProfileName(AwsProfileNameLoader.java:72)
at com.amazonaws.auth.profile.internal.AwsProfileNameLoader.loadProfileName(AwsProfileNameLoader.java:54)
at com.amazonaws.regions.AwsProfileRegionProvider.<init>(AwsProfileRegionProvider.java:40)
at com.amazonaws.regions.DefaultAwsRegionProviderChain.<init>(DefaultAwsRegionProviderChain.java:23)
at com.amazonaws.client.builder.AwsClientBuilder.<clinit>(AwsClientBuilder.java:58)
at com.lmig.global.event.framework.sample.publisher.application.code.Attestation.main(Attestation.java:18)
线程“main”java.lang.NoSuchMethodError中的异常:com.amazonaws.util.StringUtils.trim(Ljava/lang/String;)Ljava/lang/String;
在com.amazonaws.auth.profile.internal.AwsProfileNameLoader.getEnvProfileName(AwsProfileNameLoader.java:72)
位于com.amazonaws.auth.profile.internal.AwsProfileNameLoader.loadProfileName(AwsProfileNameLoader.java:54)
位于com.amazonaws.regions.AwsProfileRegionProvider。(AwsProfileRegionProvider.java:40)
位于com.amazonaws.regions.DefaultAwsRegionProviderChain。(DefaultAwsRegionProviderChain.java:23)
位于com.amazonaws.client.builder.AwsClientBuilder.(AwsClientBuilder.java:58)
位于com.lmig.global.event.framework.sample.publisher.application.code.detection.main(detection.java:18)
类路径中似乎有许多版本的SDK。您可以尝试打印加载类的位置吗
System.out.println(StringUtils.getClass().getProtectionDomain().getCodeSource());
System.out.println(AwsProfileNameLoader.getClass().getProtectionDomain().getCodeSource());