2

我正在尝试在wildfly 10.1.0.Final上使用http 补丁方法运行 rest api 。如果我在此端点上发出请求,我会收到405 Method Not Allowed

我使用javax.javaee-api:8.0

补丁

@PATCH
@Path("/documents/{id}")
public Response patchDocument(@PathParam("id") String id,
        @ApiParam(value = "", required = true) @Valid PatchRequestSTO jsonPatch) {
    return ok(jsonPatch.toString()).build();
}

响应:405 方法不允许

Allow:OPTIONS, PUT
Connection:keep-alive
Content-Length:0
Date:Fri, 05 Jan 2018 07:55:44 GMT
Server:WildFly/10
X-Powered-By:Undertow/1

放:

@PUT
@Path("/documents/{id}")
public Response putDocument(@PathParam("id") String id,
        @ApiParam(value = "", required = true) @Valid PatchRequestSTO jsonPatch) {
    return ok(jsonPatch.toString()).build();
}

响应:200 好

4

1 回答 1

1

您是否在项目中使用javax.javaee-api:8.0依赖项?这还不足以在 WildFly 10.1.0.Final 上运行 Java EE 8 应用程序,因为 Wildfly 不支持它。

因此,您需要一个支持 JavaEE 8 的应用程序服务器(GlassfishOpen Liberty等)来使用新功能。

于 2018-01-05T09:45:09.557 回答