我尝试使用jersey创建一个简单的get请求 但是有例外 谁能告诉我哪里弄错了?
该摘要是 - "由以下原因引起:org.glassfish.jersey.server.model.ModelValidationException:在应用程序初始化期间,应用程序资源模型的验证失败。 "
VersionResource.java
@Path("/versions")
public class VersionResource extends BaseResource<VersionDao, VersionTable>
{
public VersionResource(VersionDao objectDao)
{
super(objectDao);
}
@Override
@Path("/getAppVersions")
@GET
@UnitOfWork
public String getAllRecords(@Context HttpServletRequest req, @QueryParam("callback") String callback) throws JsonProcessingException
{
return super.getAllRecords(req, callback);
}
}
VersionTable.java
@Entity(name = "Versions")
@Table(name = "Versions")
@NamedQueries({ @NamedQuery(name = QueryNames.QUERY_VERSION_GET_ALL, query = "select c from Versions c"), })
public class VersionTable extends baseDataBase implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "VersionId")
private short versionId;
@Column(name = "VersionPlatform")
@JsonProperty
@NotEmpty
private String versionPlatform;
@Column(name = "VersionNumber")
@JsonProperty
@NotEmpty
private String versionNumber;
@Column(name = "VersionDescription")
@JsonProperty
@NotEmpty
private String versionDescription;
public short getVersionId()
{
return versionId;
}
public void setVersionId(short versionId)
{
this.versionId = versionId;
}
public String VersionPlatformEnum()
{
return versionPlatform;
}
public void setVersionPlatform(String versionPlatform)
{
this.versionPlatform = versionPlatform;
}
public String getVersionNumber()
{
return versionNumber;
}
public void setVersionNumber(String versionNumber)
{
this.versionNumber = versionNumber;
}
public String getVersionDescription()
{
return versionDescription;
}
public void setVersionDescription(String versionDescription)
{
this.versionDescription = versionDescription;
}
}
VersionDao.java
public class VersionDao extends baseAbstractDao<VersionTable> implements IDatabaseActions<VersionTable>
{
public VersionDao(SessionFactory sessionFactory)
{
super(sessionFactory);
}
@Override
public ObjectDaoResponse getAllTableRecords() throws JsonProcessingException
{
List<VersionTable> list = list(namedQuery(QueryNames.QUERY_VERSION_GET_ALL));
return ObjectDaoResponse.getAnOkResponse(list);
}
}
答案 0 :(得分:0)
我认为你的VersionResource类需要一个no arg构造函数,但是如果你真的需要一个参数,那么值应该通过注入传递(参见:https://jersey.java.net/documentation/latest/jaxrs-resources.html#d0e2643)