我正在使用《理解 Rust 中的闭包》中的示例。。我定义了以下结构:
struct MyStruct {
text: &'static str,
number: u32,
}
impl MyStruct {
fn new(text: &'static str, number: u32) -> MyStruct {
MyStruct {
text: text,
number: number,
}
}
// We have to specify that 'self' is an argument.
fn get_number(&self) -> u32 {
self.number
}
// We can specify different kinds of ownership and mutability of self.
fn inc_number(&mut self) {
self.number += 1;
}
// There are three different types of 'self'
fn …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的客户端使用PATCH方法使用JAX-RS的CXF实现.起初我将PATCH注释定义为
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@HttpMethod("PATCH")
public @interface PATCH {
}
Run Code Online (Sandbox Code Playgroud)
引用这里写的内容: 如何为JAX-RS提供@PATCH注释?
然后我发现@PATCH被添加到CXF 3.1.2中,所以我在我的maven的pom.xml中更改了版本,确实有public @interface PATCH内部版本,package org.apache.cxf.jaxrs.ext;代码实际上看起来与我上面发布的完全相同.
但是,当我尝试在我的服务定义上使用此注释时
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public interface AbcService {
@PATCH
@Path("/abc/efg")
public SomeDTO patchSomething(RequestObject request);
}
Run Code Online (Sandbox Code Playgroud)
我最终得到了java.net.ProtocolException: Invalid HTTP method: PATCH上面发布的queston链接中的说法.他们用Jersey讨论了一些解决方案,但是我可以在CXF中做什么,以便我可以使用:
AbcService abcService = JAXRSClientFactory.create(myURI, AbcService.class, myProviders, true);
abcService.patchSomething(new RequestObject('something'));
Run Code Online (Sandbox Code Playgroud)
所以我有几个问题: