英文:
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.1
的 javax.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)
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论