JAX-RS 2.1.1 构建响应时出现错误。

huangapple go评论68阅读模式
英文:

JAX-RS 2.1.1 Response building throwing error

问题

无论我使用以下哪种方式:

return Response.ok().build();

或者

return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();

都会抛出错误:

java.lang.AbstractMethodError: javax.ws.rs.core.Response$ResponseBuilder.status(ILjava/lang/String;)Ljavax/ws/rs/core/Response$ResponseBuilder;
    
at javax.ws.rs.core.Response$ResponseBuilder.status(Response.java:897)
at javax.ws.rs.core.Response.status(Response.java:568)
at javax.ws.rs.core.Response.status(Response.java:579)

Jar 文件是 javax.ws.rs-api-2.1.1.jar。我感到困惑。在 mvn dependency:tree 日志中,我只看到了三个版本为 2.1.1javax.ws.rs 条目。我以前从某些其他依赖项中排除了这个构件,因为它们引入了 2.0 版本。请提供建议。

英文:

Whether I do

return Response.ok().build();

or

return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();

its throwing me error:

java.lang.AbstractMethodError: javax.ws.rs.core.Response$ResponseBuilder.status(ILjava/lang/String;)Ljavax/ws/rs/core/Response$ResponseBuilder;
    
at javax.ws.rs.core.Response$ResponseBuilder.status(Response.java:897)
at javax.ws.rs.core.Response.status(Response.java:568)
at javax.ws.rs.core.Response.status(Response.java:579)

JAX-RS 2.1.1 构建响应时出现错误。

Jar is javax.ws.rs-api-2.1.1.jar. I am confused. In the mvn dependency:tree log, I see only three entries of javax.ws.rs with above version. I had earlier excluded this artifact from some other dependencies as they were brining 2.0. Please suggest.

答案1

得分: 0

这似乎是您缺少了该API的运行时/实现。
您需要一个像Glassfish、Tomcat这样的服务器,以实现该API,以便运行该代码。

英文:

This looks like you are missing a runtime/implementation of that API.
You need a server like Glassfish, Tomcat that implements that API in order to run the code.

huangapple
  • 本文由 发表于 2020年8月5日 02:55:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/63253409.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定