`

REST web Services 的问题 “does not have a no-arg default constructor”

 
阅读更多

最近由于项目需要,研究后决定是REST web Services,在开发中遇到报错如下:

 

 

严重: Mapped exception to response: 500 (Internal Server Error)
javax.ws.rs.WebApplicationException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
com.hnyxsm.entry.dataExchange.TDsInterface does not have a no-arg default constructor.
	this problem is related to the following location:
		at com.hnyxsm.entry.dataExchange.TDsInterface

 百度 谷歌无数,唯一一个对号的文章,图片不能显示。

 

万般无奈下,百度“ does not have a no-arg default constructor”的英文意思。问题终于解决了。

 

下面是原错误文件代码

 

 

package com.hnyxsm.entry.dataExchange;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="TDsInterface")
/**
 * 数据交换--接口管理
 * @author SuperYuan
 */
public class TDsInterface implements java.io.Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -1693894354995782167L;
	
	private int id;/* 主键 */
	private String title; /* 接口标题 */
	private String identificationCode;/* 识别码 */
	private String introdution; /* 功能简介 */
	private String sqlCode;/* sql语句 */
	private String reDateType;/* 返回数据类型 */
	private int reDateNumber;/* 返回数据条数 */
	
	
	public TDsInterface(int id, String title, String identificationCode,
			String introdution, String sqlCode, String reDateType,
			int reDateNumber) {
		this.id = id;
		this.title = title;
		this.identificationCode = identificationCode;
		this.introdution = introdution;
		this.sqlCode = sqlCode;
		this.reDateType = reDateType;
		this.reDateNumber = reDateNumber;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getIntrodution() {
		return introdution;
	}

	public void setIntrodution(String introdution) {
		this.introdution = introdution;
	}

	public String getIdentificationCode() {
		return identificationCode;
	}

	public void setIdentificationCode(String identificationCode) {
		this.identificationCode = identificationCode;
	}

	public String getSqlCode() {
		return sqlCode;
	}

	public void setSqlCode(String sqlCode) {
		this.sqlCode = sqlCode;
	}

	public String getReDateType() {
		return reDateType;
	}

	public void setReDateType(String reDateType) {
		this.reDateType = reDateType;
	}

	public int getReDateNumber() {
		return reDateNumber;
	}

	public void setReDateNumber(int reDateNumber) {
		this.reDateNumber = reDateNumber;
	}
}

 

这是纠正后,能正确运行的代码:

 

package com.hnyxsm.entry.dataExchange;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="TDsInterface")
/**
 * 数据交换--接口管理
 * @author SuperYuan
 */
public class TDsInterface implements java.io.Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -1693894354995782167L;
	
	private int id;/* 主键 */
	private String title; /* 接口标题 */
	private String identificationCode;/* 识别码 */
	private String introdution; /* 功能简介 */
	private String sqlCode;/* sql语句 */
	private String reDateType;/* 返回数据类型 */
	private int reDateNumber;/* 返回数据条数 */
	public TDsInterface() {//关键就是这个,有了它,问题纠正
		super();
	}	
	public TDsInterface(int id, String title, String identificationCode,
			String introdution, String sqlCode, String reDateType,
			int reDateNumber) {
		this.id = id;
		this.title = title;
		this.identificationCode = identificationCode;
		this.introdution = introdution;
		this.sqlCode = sqlCode;
		this.reDateType = reDateType;
		this.reDateNumber = reDateNumber;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getIntrodution() {
		return introdution;
	}

	public void setIntrodution(String introdution) {
		this.introdution = introdution;
	}

	public String getIdentificationCode() {
		return identificationCode;
	}

	public void setIdentificationCode(String identificationCode) {
		this.identificationCode = identificationCode;
	}

	public String getSqlCode() {
		return sqlCode;
	}

	public void setSqlCode(String sqlCode) {
		this.sqlCode = sqlCode;
	}

	public String getReDateType() {
		return reDateType;
	}

	public void setReDateType(String reDateType) {
		this.reDateType = reDateType;
	}

	public int getReDateNumber() {
		return reDateNumber;
	}

	public void setReDateNumber(int reDateNumber) {
		this.reDateNumber = reDateNumber;
	}
}
3
1
分享到:
评论
3 楼 ajian0051 2015-03-23  
缺少一个无参的构造方法!谢谢博主
2 楼 fch7120mn 2012-09-19  
不错,解决了我一个问题
1 楼 xiang520jl 2012-07-05  
我也遇到了这样的问题  ,,,是什么原因导致的啊。。。

相关推荐

Global site tag (gtag.js) - Google Analytics