- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在java类中有两个方法,它们被定义为包含以下方法的 Jersey 资源
@Path("base_endpoint")
public class ComplaintSupportResource{
@Post
@Path("/endPoint")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public Response complaintRegister(ComplaintDTO caliamtDTO) {
ComplaintResponseDTO response =complaintService.registerComplaint(caliamtDTO);
return Response.ok(response).build();
}
}
这是 dto 类:
@XmlRootElement公共(public)类 ComplaintDTO {
private String memberName;
private String email;
private String mobileNO;
private String complaintId;
private String claimNo;
private String complaintDetails;
private String policyNo;
public String getComplaintId() {
return complaintId;
}
public void setComplaintId(String complaintId) {
this.complaintId = complaintId;
}
public String getClaimNo() {
return claimNo;
}
public void setClaimNo(String claimNo) {
this.claimNo = claimNo;
}
public String getComplaintDetails() {
return complaintDetails;
}
public void setComplaintDetails(String complaintDetails) {
this.complaintDetails = complaintDetails;
}
public String getPolicyNo() {
return policyNo;
}
public void setPolicyNo(String policyNo) {
this.policyNo = policyNo;
}
public String getMemberName() {
return memberName;
}
public void setMemberName(String memberName) {
this.memberName = memberName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getMobileNO() {
return mobileNO;
}
public void setMobileNO(String mobileNO) {
this.mobileNO = mobileNO;
}
}
我收到以下异常。我不确定我做错了什么。
SEVERE: A sub-resource locator, public javax.ws.rs.core.Response com.xxx.xxx.xxxComplaintSupportResource.complaintRegister(com.xxx.xxx.xxx.ComplaintDTO), can not have an entity parameter. Try to move the parameter to the corresponding resource method.
SEVERE: Missing dependency for method public javax.ws.rs.core.Response com.xxx.xxx.xxxComplaintSupportResource.complaintRegister(com.xxx.xxx.xxx.ComplaintDTO) at parameter at index 0
org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
com.sun.jersey.spi.inject.Errors$ErrorMessagesException
at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790)
at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:509)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:339)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1142)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1089)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:773)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
下面的实现有什么问题。我还实现了其他端点,它们工作正常。
最佳答案
@Post 注释不正确,可能是您从其他库导入,它们 Jerysey @POST 注释是不同的,并确保您正在导入 javax.ws.rs.POST。将@Post 更改为@POST,如下所示:
@Path("base_endpoint")
public class ComplaintSupportResource{
**@POST**
@Path("/endPoint")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public Response complaintRegister(ComplaintDTO caliamtDTO) {
ComplaintResponseDTO response =complaintService.registerComplaint(caliamtDTO);
return Response.ok(response).build();
}
}
关于java - 错误 Java Jersey com.sun.jersey.spi.inject.Errors$ErrorMessagesException 在 com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java :170),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59728352/
我正在使用 Jersy 开发 REST 网络服务,这是我的简单代码: @GET @Path("/retrieveCustomerInformation/{jsonString}") @Produces
我在使用 jersey (1.8)、maven 和 hibernate 时遇到问题。 我收到此错误(“完整”日志) INFO: Scanning for root resource a
我将 Jersey API 用于 Web 服务。我正在将多部分数据从客户端发送到服务器。当 Web 服务开始执行时,我遇到了异常。 @POST @Path("uploadphoto") @Consum
我在java类中有两个方法,它们被定义为包含以下方法的 Jersey 资源 @Path("base_endpoint") public class ComplaintSupportResource{
我是一名优秀的程序员,十分优秀!