namespace java com.example.thrift namespace py example.thrift struct Person { 1: required string name; 2: optional i32 age; } service HelloWorld { string sayHello(1: string name); } thrift --gen java example.thrift import com.example.thrift.*; public class Main { public static void main(String[] args) { try { TTransport transport = new TSocket("localhost", 9090); transport.open(); TProtocol protocol = new TBinaryProtocol(transport); HelloWorld.Client client = new HelloWorld.Client(protocol); String result = client.sayHello("Alice"); System.out.println(result); transport.close(); } catch (Exception e) { e.printStackTrace(); } } }


上一篇:
下一篇:
切换中文