0

我的数据库中有一个 Employee 表,其中包含字段 empId、empName、Dept、DOJ、DoB、Sex、Qualification 和很多记录。

我有服务和道类,我的 EMP Java 资源类如下

@Entity
@Table(name="EMP")
@XmlRootElement(name = "EmpResource")
public class Employee{

    private String empId;
    private String empName;
    private String href; // this field doesn't exist in the database table.

    @XmlElement
    public String getEmpId(){
        return empId;
    }

    @XmlElement
    public String getEmpName(){
        return empId;
    }

    @XmlAttribute
    public String getHref(){
        return "http://host/rest/v1/employees/" + empId;
    }

}


我正在创建一个基于 REST 的 url,其中 url http://host/rest/v1/employees获取只有 EmpId、EmpName 和 href 字段的所有记录,但是当我尝试运行应用程序时出现此错误

javax.xml.bind.JAXBException: class com.vargo.EmpResource nor any of its super class is known to this context.

有什么帮助吗?

问候, 基查

4

1 回答 1

0

好吧,似乎问题出在包含数据的 xml 的投标中(我没有看到该代码),但请确保您提供了正确的路径:

JAXBContext jc = JAXBContext.newInstance("pathWhereYourGeneratedJaxbClassesAre");

希望这会有所帮助。

于 2012-04-09T15:42:44.080 回答