ModelValidationException jersey自定义对象

时间:2016-03-15 14:31:39

标签: java angularjs jersey jackson

我正在使用angularjs,jersey和Jackson构建应用程序。

我的angularjs方法:

services.factory('newDBFactory', function ($resource) {
return $resource('/easyshow/api/folders/angu/:scannedShows', {}, {
    save: {
        method: 'POST',
        params: {scannedShows : '@scannedShows'},
        isArray: true
    }
})

});

应该叫我的球衣方法:

@POST
@javax.ws.rs.Path("/angu/{scannedShows}")
@Consumes(MediaType.APPLICATION_JSON)
public String testAngu(@PathParam("scannedShows") List<ScannedShow> scannedShows) {
    return "YEAH";
}

但是当我尝试运行调试我的应用程序时,出现错误:

Exception in thread "main" org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.

以下是我的对象:ScanedShow

package com.businessLogic;

import com.fasterxml.jackson.annotation.JsonProperty;

public class ScannedShow {

public ScannedShow() {
}

@JsonProperty("name")
private String name;

@JsonProperty("properties")
private ShowProperties properties;

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public ShowProperties getProperties() {
    return properties;
}

public void setProperties(ShowProperties properties) {
    this.properties = properties;
}
}

和ShowProperties:

public class ShowProperties {

public ShowProperties(){
}

@JsonProperty("id")
private String id;

@JsonProperty("seriesName")
private String seriesName;

@JsonProperty("firstAired")
private String firstAired;

@JsonProperty("overview")
private String overview;

public String getId() {
    return id;
}
public void setId(String id) {
    this.id = id;
}
public String getSeriesName() {
    return seriesName;
}
public void setSeriesName(String seriesName) {
    this.seriesName = seriesName;
}
public String getFirstAired() {
    return firstAired;
}
public void setFirstAired(String firstAired) {
    this.firstAired = firstAired;
}
public String getOverview() {
    return overview;
}
public void setOverview(String overview) {
    this.overview = overview;
}
}

0 个答案:

没有答案