Jpa 带UUID的Spring数据REST:PersistentEntity没有标识符属性

Jpa 带UUID的Spring数据REST:PersistentEntity没有标识符属性,jpa,spring-boot,spring-data,spring-data-jpa,spring-data-rest,Jpa,Spring Boot,Spring Data,Spring Data Jpa,Spring Data Rest,我使用Spring数据和REST starter来提供由UUID标识的设备实体的存储库 my pom.xml中的相关工件(使用Spring Boot版本1.5.3.RELEASE) 从DeviceDB类中提取(它实际上是数据库映射的包装器) 从设备类中提取(使用Gson进行JSON序列化) 以下是存储库: public interface DeviceRepository extends CrudRepository<DeviceDB, UUID> { } 但是,该对象确实提供了有

我使用Spring数据和REST starter来提供由UUID标识的设备实体的存储库

my pom.xml中的相关工件(使用Spring Boot版本
1.5.3.RELEASE

DeviceDB
类中提取(它实际上是数据库映射的包装器)

设备
类中提取(使用Gson进行JSON序列化)

以下是存储库:

public interface DeviceRepository extends CrudRepository<DeviceDB, UUID> { }
但是,该对象确实提供了有效的UUID,并且序列化/反序列化似乎正在工作

该职位要求如下:

curl -X POST -H "Content-Type: application/json" -d '{ "device": { "id" : "81e033a7-3b13-4581-b6f4-91616781f9ce" }}' localhost:8090/devices

你能给我们看一下post请求吗?好的,我把它添加到了问题中。UUID是否使用了类?如果使用Long作为标识符,那么它将工作。我在存储库、映射类和请求中将UUID更改为Long,但没有,出现相同的异常。回避了一个问题,为什么Spring Data JPA坚持自己检查元数据,而JPA提供商负责所有这些!
@SerializedName(value = "id")
private UUID deviceId;

public UUID getId() {
    return deviceId;
}

public void setId(UUID deviceId) {
    this.deviceId = deviceId;
}
public interface DeviceRepository extends CrudRepository<DeviceDB, UUID> { }
java.lang.IllegalArgumentException: PersistentEntity does not have an identifier property!
at org.springframework.util.Assert.isTrue(Assert.java:92) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.data.mapping.model.IdPropertyIdentifierAccessor.<init>(IdPropertyIdentifierAccessor.java:47) ~[spring-data-commons-1.13.3.RELEASE.jar:na]
at org.springframework.data.jpa.mapping.JpaPersistentEntityImpl$JpaProxyAwareIdentifierAccessor.<init>(JpaPersistentEntityImpl.java:119) ~[spring-data-jpa-1.11.3.RELEASE.jar:na]
at org.springframework.data.jpa.mapping.JpaPersistentEntityImpl.getIdentifierAccessor(JpaPersistentEntityImpl.java:73) ~[spring-data-jpa-1.11.3.RELEASE.jar:na]
at org.springframework.data.rest.core.support.DefaultSelfLinkProvider.getResourceId(DefaultSelfLinkProvider.java:97) ~[spring-data-rest-core-2.6.3.RELEASE.jar:na]
at org.springframework.data.rest.core.support.DefaultSelfLinkProvider.createSelfLinkFor(DefaultSelfLinkProvider.java:70) ~[spring-data-rest-core-2.6.3.RELEASE.jar:na]
at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.getSelfLinkFor(PersistentEntityResourceAssembler.java:99) ~[spring-data-rest-webmvc-2.6.3.RELEASE.jar:na]
at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.wrap(PersistentEntityResourceAssembler.java:76) ~[spring-data-rest-webmvc-2.6.3.RELEASE.jar:na]
at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toFullResource(PersistentEntityResourceAssembler.java:67) ~[spring-data-rest-webmvc-2.6.3.RELEASE.jar:na]
at org.springframework.data.rest.webmvc.RepositoryEntityController.createAndReturn(RepositoryEntityController.java:488) ~[spring-data-rest-webmvc-2.6.3.RELEASE.jar:na]
at org.springframework.data.rest.webmvc.RepositoryEntityController.postCollectionResource(RepositoryEntityController.java:272) ~[spring-data-rest-webmvc-2.6.3.RELEASE.jar:na]
curl -X POST -H "Content-Type: application/json" -d '{ "device": { "id" : "81e033a7-3b13-4581-b6f4-91616781f9ce" }}' localhost:8090/devices