You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Java后端查询DynamoDB时遇InvalidSignatureException问题求助

DynamoDB查询报InvalidSignatureException问题排查与解决

我是一名软件实习生,正在开发Java后端以查询DynamoDB表。目前我们正在切换到新的表结构,新表包含哈希键和排序键,而旧表仅使用哈希键。以下是查询该表的方法:

public String getCommuterOptions(String crewID) throws JsonProcessingException {
           String hashKey = crewID;
           String rangeKey = "E";
           CommuterOptionsRequest response = dynamoDBMapper.load(CommuterOptionsRequest.class, hashKey, rangeKey, 
DynamoDBMapperConfig.TableNameOverride.withTableNameReplacement(applicationProperties.getProfileTableNm()).config());
           return ServiceUtil.convertErrorObjectToJson(response, "Success");
}

注:此查询的排序键需为"E"。

运行应用时出现如下错误:

"Unable to unmarshall exception response with the unmarshallers provided (Service: 
AmazonDynamoDBv2; Status Code: 400; Error Code: InvalidSignatureException; Request ID:
6LVEKJAFGBBPM3NB7U4LE60P13VV4KQNSO5AEMVJF66Q9ASUAAJG; Proxy: null)"

已尝试的操作:

  • 改用.query()方法查询,得到相同错误
  • 反复检查系统时间、Secret Key和Access Key,未发现异常
  • 旧表的控制器设计逻辑与此方法类似,可正常工作

更新1:项目依赖项如下

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>
        <!-- marked the embedded servlet container as provided -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
         <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>4.0.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-dynamodb</artifactId>
            <version>1.11.330</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.json/json -->
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20180130</version>
        </dependency>

        <!--<dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-text</artifactId>
            <version>1.1</version>
        </dependency>

        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>javax.mail</artifactId>
        </dependency>
          <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.10</version>
        </dependency>-->
</dependencies>

更新2:问题已解决

更新了依赖项,获取了新的Access Key和Secret Key,同时对DTO的哈希键和排序键注解做了细微调整,问题已解决。感谢大家的帮助。


内容的提问来源于stack exchange,提问作者DA_C5_012

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 08:24:18