在我的代码中venue
和coach
是实体并且都有照片,当我修补教练实体时,它工作正常但是当我想修补教练资源时它会给我以下错误
有人可以解释是什么问题吗?
Coach.java
@Entity
public class Coach implements CoachGetter,Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(nullable=false)
private String name;
private String extras;
@ManyToOne
@NotNull
private Sport sport;
@OneToOne(mappedBy="coach",targetEntity=CoachPhoto.class)
private CoachPhoto coachPhoto;
//getters and setters
}
Venuehoto
@Entity
public class VenuePhoto {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@ManyToOne
private Venue venue;
private String path;
// getters and setters }
CoachPhoto
@Entity
public class CoachPhoto {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@OneToOne
private Coach coach;
private String path;
}
venue.java
@Entity
public class Venue {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(nullable=false)
private String name;
private Boolean enabled=true;
private Double latitude;
private Double longitude;
@ManyToMany
private Set<Sport> sport;
@OneToMany(mappedBy="venue",targetEntity=VenuePhoto.class)
private List <VenuePhoto> venuePhotos;
//getters and setters
}
教练补丁请求
{
"name": "John",
"id": 6,
"sport": "http://localhost:3000/api/sports/6",
"coachPhoto": {
"id": 8,
"path": "coachPhotos/8.jpg"
},
"extras": null
}
场地补丁请求
{
"name": "National Stadium",
"id": 5,
"enabled": true,
"latitude": 25.203927,
"longitude": 55.271077,
"venuePhotos": [
{
"path": "venuePhotos/3.jpg"
},
{
"path": "venuePhotos/6.jpg"
}
]
}
错误
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Failed to convert from type [java.net.URI] to type [com.ivl.MySportsAcademy.model.VenuePhoto] for value 'path'; nested exception is java.lang.IllegalArgumentException: Cannot resolve URI path. Is it local or remote? Only local URIs are resolvable. (through reference chain: com.ivl.MySportsAcademy.model.Venue["venuePhotos"]->java.util.ArrayList[1])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:388) ~[jackson-databind-2.8.10.jar:2.8.10]
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:360) ~[jackson-databind-2.8.10.jar:2.8.10]
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:308) ~[jackson-databind-2.8.10.jar:2.8.10]
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:259) ~[jackson-databind-2.8.10.jar:2.8.10]
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26) ~[jackson-databind-2.8.10.jar:2.8.10]
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:504) ~[jackson-databind-2.8.10.jar:2.8.10]
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:104) ~[jackson-databind-2.8.10.jar:2.8.10]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:240) ~[jackson-databind-2.8.10.jar:2.8.10]
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1628) ~[jackson-databind-2.8.10.jar:2.8.10]
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1301) ~[jackson-databind-2.8.10.jar:2.8.10]
at org.springframework.data.rest.webmvc.json.DomainObjectReader.doMerge(DomainObjectReader.java:279) ~[spring-data-rest-webmvc-2.6.9.RELEASE.jar:na]
at org.springframework.data.rest.webmvc.json.DomainObjectReader.read(DomainObjectReader.java:87) ~[spring-data-rest-webmvc-2.6.9.RELEASE.jar:na]
... 101 common frames omitted
Caused by: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.net.URI] to type [com.ivl.MySportsAcademy.model.VenuePhoto] for value 'path'; nested exception is java.lang.IllegalArgumentException: Cannot resolve URI path. Is it local or remote? Only local URIs are resolvable.
at org.springframework.data.rest.core.UriToEntityConverter.convert(UriToEntityConverter.java:119) ~[spring-data-rest-core-2.6.9.RELEASE.jar:na]
at org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module$UriStringDeserializer.deserialize(PersistentEntityJackson2Module.java:518) ~[spring-data-rest-webmvc-2.6.9.RELEASE.jar:na]
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:287) ~[jackson-databind-2.8.10.jar:2.8.10]
... 110 common frames omitted
Caused by: java.lang.IllegalArgumentException: Cannot resolve URI path. Is it local or remote? Only local URIs are resolvable.
... 113 common frames omitted