<bdo id='NJ5fs'></bdo><ul id='NJ5fs'></ul>
  1. <tfoot id='NJ5fs'></tfoot>
    <legend id='NJ5fs'><style id='NJ5fs'><dir id='NJ5fs'><q id='NJ5fs'></q></dir></style></legend>
  2. <small id='NJ5fs'></small><noframes id='NJ5fs'>

      <i id='NJ5fs'><tr id='NJ5fs'><dt id='NJ5fs'><q id='NJ5fs'><span id='NJ5fs'><b id='NJ5fs'><form id='NJ5fs'><ins id='NJ5fs'></ins><ul id='NJ5fs'></ul><sub id='NJ5fs'></sub></form><legend id='NJ5fs'></legend><bdo id='NJ5fs'><pre id='NJ5fs'><center id='NJ5fs'></center></pre></bdo></b><th id='NJ5fs'></th></span></q></dt></tr></i><div id='NJ5fs'><tfoot id='NJ5fs'></tfoot><dl id='NJ5fs'><fieldset id='NJ5fs'></fieldset></dl></div>

      简单的 DynamoDB 请求失败并出现 ResourceNotFoundExce

      时间:2023-09-29
        <tfoot id='kgPm1'></tfoot>

            <bdo id='kgPm1'></bdo><ul id='kgPm1'></ul>
              <legend id='kgPm1'><style id='kgPm1'><dir id='kgPm1'><q id='kgPm1'></q></dir></style></legend>

                <tbody id='kgPm1'></tbody>

              <small id='kgPm1'></small><noframes id='kgPm1'>

                <i id='kgPm1'><tr id='kgPm1'><dt id='kgPm1'><q id='kgPm1'><span id='kgPm1'><b id='kgPm1'><form id='kgPm1'><ins id='kgPm1'></ins><ul id='kgPm1'></ul><sub id='kgPm1'></sub></form><legend id='kgPm1'></legend><bdo id='kgPm1'><pre id='kgPm1'><center id='kgPm1'></center></pre></bdo></b><th id='kgPm1'></th></span></q></dt></tr></i><div id='kgPm1'><tfoot id='kgPm1'></tfoot><dl id='kgPm1'><fieldset id='kgPm1'></fieldset></dl></div>
              • 本文介绍了简单的 DynamoDB 请求失败并出现 ResourceNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我刚刚开始使用 Java SDK (v1.8) 运行 DynamoDB.我使用 AWS 控制台创建了一个非常简单的表.我的表有一个主哈希键,它是一个字符串(无范围).我已经将一个项目与其他 4 个属性值(所有字符串)一起放入表中.

                I'm just getting up and running with DynamoDB using the Java SDK (v1.8). I've created a very simple table using the AWS console. My table has a primary hash key, which is a String (no range). I've put a single item into the table with 4 other attribute values (all Strings).

                我正在为表中的该项目发出一个简单的 Java 请求,但它失败并出现 ResourceNotFoundException.我绝对肯定我提供的表名是正确的,我用来查询项目的主哈希键的名称也是正确的.表状态在 AWS 控制台中列为 Active,我也可以看到该项目及其值.

                I'm making a simple Java request for that item in the table, but it's failing with ResourceNotFoundException. I'm absolutely positive that the table name I'm supplying is correct, as is the name of the primary hash key that I'm using to query the item. The table status is listed in the AWS console as Active and I can see the item and its values too.

                这是我得到的错误:

                Requested resource not found (Service: AmazonDynamoDB; Status Code: 400; Error Code: ResourceNotFoundException; Request ID: ...)
                

                我尝试了以下方法(使用类的 dynamodbv2 版本):

                I've tried the following (using the dynamodbv2 versions of the classes):

                Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
                key.put(PRIMARY_KEY, new AttributeValue().withS(value));
                
                GetItemRequest request = new GetItemRequest()
                    .withTableName(TABLE_NAME)
                    .withKey(key);
                
                GetItemResult result = client.getItem(request);
                

                我也尝试过使用所有这些类的旧版本,已弃用,如下所示:

                I've also tried using the older, deprecated versions of all these classes, like this:

                GetItemRequest request = new GetItemRequest()
                        .withTableName(TABLE_NAME)
                        .withKey(new Key().withHashKeyElement(new AttributeValue().withS(value)));
                GetItemResult result = client.getItem(request);
                

                ...但结果相同.
                我对 ResourceNotFoundException 的理解是,它表示引用的表名或属性无效,事实并非如此.如果表太早处于Creating状态也可以抛出,但是我的表是Active.

                ...but it's the same result.
                My understanding of the ResourceNotFoundException is that it means the table name or attribute referenced is invalid, which is not the case. It can also be thrown if the table is too early in the Creating state, but my table is Active.

                推荐答案

                请求失败,因为我在发出请求之前没有为客户端设置区域.默认区域可能是美国东部,而我的表设置在欧洲西部.这修复了它:

                The request was failing because I wasn't setting the region for the client before making the request. The default region is probably US East and my table is setup in EU West. This fixed it:

                import com.amazonaws.regions.Region;
                import com.amazonaws.regions.Regions;
                
                client.setRegion(Region.getRegion(Regions.EU_WEST_1));
                

                这篇关于简单的 DynamoDB 请求失败并出现 ResourceNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何使用 Java 设置 DynamoDB 返回的匹配项的限制 下一篇:DynamoDB 查询 JSON 对象的子字段

                相关文章

                最新文章

                  <bdo id='J4qso'></bdo><ul id='J4qso'></ul>

                  1. <legend id='J4qso'><style id='J4qso'><dir id='J4qso'><q id='J4qso'></q></dir></style></legend>
                    <tfoot id='J4qso'></tfoot>

                    <i id='J4qso'><tr id='J4qso'><dt id='J4qso'><q id='J4qso'><span id='J4qso'><b id='J4qso'><form id='J4qso'><ins id='J4qso'></ins><ul id='J4qso'></ul><sub id='J4qso'></sub></form><legend id='J4qso'></legend><bdo id='J4qso'><pre id='J4qso'><center id='J4qso'></center></pre></bdo></b><th id='J4qso'></th></span></q></dt></tr></i><div id='J4qso'><tfoot id='J4qso'></tfoot><dl id='J4qso'><fieldset id='J4qso'></fieldset></dl></div>

                    <small id='J4qso'></small><noframes id='J4qso'>