我正在尝试将一个人对象传递给下面的测试方法,但是当我尝试在邮递员中运行它时,我收到了一个错误。任何帮助将不胜感激
在邮递员中,我在正文中使用了以下JSON
{
"name" : "aasd",
"address" : "asd",
"age" : "asdads",
"sex" : "asdsad"
}
人物模型
package com.test.model;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.math.BigDecimal;
import java.util.Date;
@XmlRootElement
public class Person{
@XmlElement
private String name;
@XmlElement
private String address;
public Person() {
}
public void setName(String name) {
this.name= name;
}
@XmlElement
public String getName() {
return name;
}
public void setAddress(String address) {
this.address= address;
}
@XmlElement
public String getAddress() {
return address;
}
}
控制器
package com.test2.controller;
import javax.annotation.security.PermitAll;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import com.test.model;
@Path("person")
public class PersonController {
@PermitAll
@POST
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON})
@Path("test")
public Person addPerson(Person person) {
return person;
}
}
错误消息
例外
javax.servlet.ServletException:org.glassfish.jersey.server.ContainerException:java.lang.NoClassDefFoundError:无法初始化类org.eclipse.persistence.jaxb.BeanValidationHelper 根本原因
org.glassfish.jersey.server.ContainerException:java.lang.NoClassDefFoundError:无法初始化类org.eclipse.persistence.jaxb.BeanValidationHelper 根本原因
java.lang.NoClassDefFoundError:无法初始化类org.eclipse.persistence.jaxb.BeanValidationHelper