我正在使用jsonrpc4j并被卡住了.我举了一个例子来说明我的问题:
抽象类:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
@JsonSubTypes(value = { @JsonSubTypes.Type(value = Walnut.class) })
public abstract class Nut {
}
Run Code Online (Sandbox Code Playgroud)
具体子类:
public class Walnut extends Nut {
}
Run Code Online (Sandbox Code Playgroud)
服务接口:
public interface ServiceInterface {
public Nut getNut();
public void setNut(Nut nut);
}
Run Code Online (Sandbox Code Playgroud)
服务本身:
public class Service implements ServiceInterface {
public Nut getNut() { return new Walnut(); }
public void setNut(Nut nut) {}
}
Run Code Online (Sandbox Code Playgroud)
服务器:
JsonRpcServer rpcServer = new JsonRpcServer(new ObjectMapper(), new Service());
StreamServer streamServer = new StreamServer(rpcServer, 50, 1420,
50, InetAddress.getByName("127.0.0.1")); …Run Code Online (Sandbox Code Playgroud)