Java AWS DynamoDBMapper save方法继续抛出`DynamoDBMappingException:不支持;需要@DynamoDBTyped或@DynamoDBTypeConverted`

Java AWS DynamoDBMapper save方法继续抛出`DynamoDBMappingException:不支持;需要@DynamoDBTyped或@DynamoDBTypeConverted`,java,spring-boot,spring-data-jpa,amazon-dynamodb,Java,Spring Boot,Spring Data Jpa,Amazon Dynamodb,我遵循了这里概述的一切-。但还是没有运气 我有一个带有哈希键和排序键的DynamoDB表 这是我最近播放的实体类。类 @DynamoDBTable(tableName="some-table") public class RecentlyPlayed { @Id private RecentlyPlayedId recentlyPlayedId; // ----- Constructor methods ----- @DynamoDBHashKey(attributeName="keyA"

我遵循了这里概述的一切-。但还是没有运气

我有一个带有哈希键和排序键的DynamoDB表

这是我最近播放的实体类。类

@DynamoDBTable(tableName="some-table")
public class RecentlyPlayed {

@Id
private RecentlyPlayedId recentlyPlayedId;

// ----- Constructor methods -----

@DynamoDBHashKey(attributeName="keyA")
// Getter and setter

@DynamoDBRangeKey(attributeName="keyB")
// Getter and setter

}
public class RecentlyPlayedId implements Serializable {

    private static final long serialVersionUID = 1L;

    private String keyA;

    private String keyB;

    public RecentlyPlayedId(String keyA, String keyB) {
        this.keyA = keyA;
        this.keyB = keyB;
    }

    @DynamoDBHashKey
    // Getter and setter

    @DynamoDBRangeKey
    // Getter and setter
}
这是我最近播放的密钥类ID.class

@DynamoDBTable(tableName="some-table")
public class RecentlyPlayed {

@Id
private RecentlyPlayedId recentlyPlayedId;

// ----- Constructor methods -----

@DynamoDBHashKey(attributeName="keyA")
// Getter and setter

@DynamoDBRangeKey(attributeName="keyB")
// Getter and setter

}
public class RecentlyPlayedId implements Serializable {

    private static final long serialVersionUID = 1L;

    private String keyA;

    private String keyB;

    public RecentlyPlayedId(String keyA, String keyB) {
        this.keyA = keyA;
        this.keyB = keyB;
    }

    @DynamoDBHashKey
    // Getter and setter

    @DynamoDBRangeKey
    // Getter and setter
}
这是我的存储库界面
RecentlyPlayedRepository

@EnableScan
public interface RecentlyPlayedRepository extends CrudRepository<RecentlyPlayed, RecentlyPlayedId> {

    List<RecentlyPlayed> findAllByKeyA(@Param("keyA") String keyA);

    // Finding the entry for keyA with highest keyB
    RecentlyPlayed findTop1ByKeyAOrderByKeyBDesc(@Param("keyA") String keyA);
}
我使用的是
SpringV2.0.1.RELEASE
。原始文档中的wiki警告此错误,并描述如何减轻此错误。我完全照他们说的做了。但还是没有运气


指向该wiki的链接位于此处-

DynamoDB仅支持基本数据类型,它不知道如何将复杂字段(recentlyPlayedId)转换为基本数据类型,例如字符串

要显示这种情况,可以将注释@DynamoDBIgnore添加到您的recentlyplayedd属性中,如下所示:

@DynamoDBIgnore
private RecentlyPlayedId recentlyPlayedId;
您还需要删除@id注释


然后,保存功能将起作用,但recentlyPlayedId将不会存储在项目中。如果确实要保存此字段,则需要使用@DynamoDBTypeConverted注释并编写一个转换器类。converter类定义如何将复杂字段转换为字符串,然后将字符串解压为复杂字段。

删除@Id字段的getter/setter为我解决了这个问题。这在

中建议不支持;需要@DynamoDBTyped或@DynamoDBTypeConverted“


当我用字段JsonNode定义模型类时,我遇到了这个错误,我将它转换为MAP,现在它运行良好

非常透明地描述了您的路径。但是指出抛出的异常可以添加为堆栈跟踪。添加
@DynamoDBIgnore
注释而不是
@Id
抱怨没有Id注释。Kee将两者同时ping会引发相同的错误。好的,我看到您使用的是第三方库而不是DynamoDBMapper。祝您好运!嗯。我使用的是
com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper
@id不是DynamoDBMapper注释将Spring和DynamoDBMapper一起使用似乎是个坏主意。