JavaFX gRPC Client Dependencies

2019-09-15 12:05发布

问题:

I am working on gRPC client(JavaFX) and server(SpringBoot with gRPC starter). The two application are independent and do not share any files together. The server is complete for testing(here)

I would like to make JavaFX client independently from the gRPC server, i.e without including gRPC server as a maven dependancy in client POM.

What gRPC client specific dependencies can i add in the javafx application and how to send request to the server?

回答1:

According to the official documentation (http://www.grpc.io/docs/quickstart/java.html) the examples can be used as a starting point https://github.com/grpc/grpc-java/blob/master/examples/build.gradle

The dependencies you need are

compile "io.grpc:grpc-netty:${grpcVersion}"
compile "io.grpc:grpc-protobuf:${grpcVersion}"
compile "io.grpc:grpc-stub:${grpcVersion}"

where ${grpcVersion} is whatever released version of gRPC you may want to use. This notation is for the Gradle build tool, however transforming to Maven coordinates is easy, such as

<dependency>
    <groupId>io.grpc</groupId>
    <artifactId>grpc-netty</artifactId>
    <version>1.2.0</version>
</dependency>

You'll find another working example at https://github.com/aalmiray/javatrove/tree/master/chat-02