Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java springrest:使用补丁编辑资源_Java_Spring_Spring Data_Spring Data Jpa_Patch - Fatal编程技术网

Java springrest:使用补丁编辑资源

Java springrest:使用补丁编辑资源,java,spring,spring-data,spring-data-jpa,patch,Java,Spring,Spring Data,Spring Data Jpa,Patch,在我的代码场馆和教练中,这两个实体都有照片,当我修补教练实体时,它工作正常,但当我想修补教练资源时,它会给我以下错误 有人能解释问题出在哪里 Coach.java @Entity public class Coach implements CoachGetter,Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = Generatio

在我的代码
场馆
教练
中,这两个实体都有照片,当我修补教练实体时,它工作正常,但当我想修补教练资源时,它会给我以下错误 有人能解释问题出在哪里

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 
}
@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
}
Venuehoto

@Entity
public class VenuePhoto {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    @ManyToOne
    private Venue venue;

    private String path;
    // getters and setters }
@Entity
public class CoachPhoto {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    @OneToOne
    private Coach coach;

    private String path;

       }
教练照片

@Entity
public class VenuePhoto {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    @ManyToOne
    private Venue venue;

    private String path;
    // getters and setters }
@Entity
public class CoachPhoto {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    @OneToOne
    private Coach coach;

    private String path;

       }
vention.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 
}
@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": "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

你也可以分享
CoachPhoto
VenuePhoto
课程吗?@Bentaye请检查更新的问题我想我帮不上忙,只是一个想法,是不是
场馆
没有实现
可序列化
,它的行为也不一样?@Bentaye我也实现了
可序列化
,但没有任何效果:|