Java Spring MVC没有';不能将链接转换为实体
我在SpringData/Jpa中有一个映射实体Java Spring MVC没有';不能将链接转换为实体,java,spring-mvc,spring-boot,spring-data,jackson-databind,Java,Spring Mvc,Spring Boot,Spring Data,Jackson Databind,我在SpringData/Jpa中有一个映射实体 @AllArgsConstructor(suppressConstructorProperties = true) @Data @Entity @Builder @Table(name = "requests") @ToString @NoArgsConstructor public class Request { @Id @GeneratedValu
@AllArgsConstructor(suppressConstructorProperties = true)
@Data
@Entity
@Builder
@Table(name = "requests")
@ToString
@NoArgsConstructor
public class Request {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String externalId;
@Enumerated(EnumType.STRING)
private DataSource dataSource;
private String requestNumber;
private Date requestDate;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "CLIENTID")
private Client clientId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="DESTINATIONPOINTID")
private Point destinationPointId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "MARKETAGENTUSERID")
private User marketAgentUserId;
private String invoiceNumber;
private Date invoiceDate;
private String documentNumber;
private Date documentDate;
private String firma;
private String storage;
private String contactName;
private String contactPhone;
private String deliveryOption;
@Temporal(TemporalType.TIMESTAMP)
private Date deliveryDate;
private Integer boxQuantity;
private Integer weight;
private Integer volume;
private BigDecimal goodsCost;
@Temporal(TemporalType.TIMESTAMP)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd.MM.yyyy HH:mm")
private Date lastStatusUpdated;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "LASTMODIFIEDBY")
private User lastModifiedBy;
@Enumerated(EnumType.STRING)
private RequestStatus requestStatusId;
private String commentForStatus;
private Integer hoursAmount;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name= "ROUTELISTID")
private RouteList routeListId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "LASTVISITEDROUTEPOINTID")
private Point lastVisitedRoutePointId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "WAREHOUSEPOINTID")
private Point warehousePoint;
@OneToMany(mappedBy = "requestId")
private List<RequestHistory> requestHistory = new ArrayList<>();
}
我将一个字符串(到实体的正确链接)从Postman传递给它,它返回一个错误消息:
"message": "JSON parse error: Cannot construct instance of `org.springframework.hateoas.Resource` (although at least one Creator exists): no String-argument
constructor/factory method to deserialize from String value ('http://localhost:8080/api/requests/8'); nested exception is
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `org.springframework.hateoas.Resource` (although at least one Creator
exists): no String-argument constructor/factory method to deserialize from String value ('http://localhost:8080/api/requests/8')\n at [Source: (
PushbackInputStream); line: 1, column: 1]",
我对这个难题感到困惑。
可能有什么问题?您能否验证在
@RequestBody Request Request
中正确导入的是您的Request
类,而不是属于其他包/库等的另一个Request
类?检查一下你的进口。是的,我很确定我的进口是正确的。在你发表评论后,我甚至检查了一下。
"message": "JSON parse error: Cannot construct instance of `org.springframework.hateoas.Resource` (although at least one Creator exists): no String-argument
constructor/factory method to deserialize from String value ('http://localhost:8080/api/requests/8'); nested exception is
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `org.springframework.hateoas.Resource` (although at least one Creator
exists): no String-argument constructor/factory method to deserialize from String value ('http://localhost:8080/api/requests/8')\n at [Source: (
PushbackInputStream); line: 1, column: 1]",