gpt4 book ai didi

java - 错误 Java Jersey com.sun.jersey.spi.inject.Errors$ErrorMessagesException 在 com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java :170)

转载 作者:行者123 更新时间:2023-12-02 09:07:03 25 4
gpt4 key购买 nike

我在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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com