我收到一個錯誤 - '類com.fasterxml.jackson.datatype.joda.deser.DateTimeDeserializer沒有默認值沒有arg)構造函數',而我正試圖調用postang請求。當我調用方法時,它會進入錯誤塊。類com.fasterxml.jackson.datatype.joda.deser.DateTimeDeserializer沒有默認的(無參數)構造函數
Restangular.all('tests').post($scope.test).then(function (data) {
$scope.test.id = data.id;
$location.path($location.path() + data.id).replace();
}, function (error) {
$scope.exceptionDetails = validationMapper(error);
});
我使用傑克遜 - 數據類型 - 約達 - 2.6.5
在此方法中使用的實體類如下 -
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@Entity
@Table(name = "Test")
@EqualsAndHashCode(of = "id", callSuper = false)
@ToString(exclude = {"keywords", "relevantObjectIds"})
public class Test {
@Id
@Column(unique = true, length = 36)
private String id;
@NotBlank
@NotNull
private String name;
@Transient
private List<Testabc> Testabcs = new ArrayList<>();
}
實體類在上述實體testAbc的使用類如下
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@Slf4j
@Entity
@Table(name = "Test_abc")
@EqualsAndHashCode(of = "id", callSuper = false)
public class Testabc{
@Id
@Column(unique = true, length = 36)
@NotNull
private String id = UUID.randomUUID().toString();
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
@JsonDeserialize(using = DateTimeDeserializer.class)
@JsonSerialize(using = DateTimeSerializer.class)
private DateTime createdOn;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "Id")
@NotNull
private t1 pid;
private long originalSize;
}
最後資源類我在哪裏請求創建測試數據 -
@ApiOperation(value = "Create new Test", notes = "Create a new Test and return with its unique id", response = Test.class)
@POST
@Timed
public Test create(Test newInstance) {
return super.create(newInstance);
}
我已嘗試添加該 @JsonIgnoreProperties(ignoreUnknown =真)註釋上的實體類,但它不工作。
任何人都可以幫助解決這個問題?
[joda.time.DateTime反序列化錯誤]的可能的複製(http://stackoverflow.com/questions/22643367/joda-time-datetime-deserialization-error) – Morfic
沒有就沒有duplicacy – Geetanjali
這是否意味着從解釋鏈接問題的答案和'mapper.registerModule(new JodaModule())'的建議解決方案;'不適合你? – Morfic