4.8.3. 在 MicroProfile REST 客户端中声明提供程序注册
使用 MicroProfile REST 客户端将 org.eclipse.microprofile.rest.client.annotation.RegisterProvider
注释添加到目标接口,如以下示例所示:
@Path("resource") @RegisterProvider(MyClientResponseFilter.class) @RegisterProvider(MyMessageBodyReader.class) public interface TestResourceIntf2 { @Path("test/{path}") @Consumes("text/plain") @Produces("text/html") @POST public String test(@PathParam("path") String path, @QueryParam("query") String query, String entity); }
使用注释 声明 MyClientResponseFilter
类和 MyMessageBodyReader
类无需调用 RestClientBuilder.register()
方法。