Reinstate changes from "Improve Gradle instructions in README.md"
The changes made in commit da5b55cbe3 were
implemented the auto-generated README rather than the adoc file that is
used to generate the README. This commit moves the changes into the
source adoc file.
Signed-off-by: Chris Bono <chris.bono@gmail.com>
This commit is contained in:
19
README.md
19
README.md
@@ -21,11 +21,14 @@ Open it in your IDE in the usual way. E.g. if you’re using IntelliJ IDEA: `ide
|
||||
|
||||
Define a `.proto` service definition file `src/main/proto/hello.proto` with the following contents:
|
||||
|
||||
**❗ IMPORTANT**\
|
||||
Be sure to change the `java_package` to the one you chose in Spring Initializr
|
||||
|
||||
```proto
|
||||
syntax = "proto3";
|
||||
|
||||
option java_multiple_files = true;
|
||||
option java_package = "org.springframework.grpc.sample.proto";
|
||||
option java_package = "<your-package-name-goes-here>.proto";
|
||||
option java_outer_classname = "HelloWorldProto";
|
||||
|
||||
// The greeting service definition.
|
||||
@@ -58,7 +61,15 @@ or
|
||||
./gradlew build
|
||||
```
|
||||
|
||||
You’ll get two new folders in the `target` directory (or `build` for Gradle): `target/target/generated-sources/protobuf/grpc-java` and `target/target/generated-sources/protobuf/java`. You may need to instruct your IDE to mark them as source roots. In IntelliJ IDEA, you’d right click the folder, choose `Mark Directory As` -> `Generated Source Root`. Eclipse or VSCode will add them automatically for you.
|
||||
Two new folders will be generated containing the source code for the stubs.
|
||||
|
||||
_For Maven_: `target/generated-sources/protobuf/grpc-java` and `target/generated-sources/protobuf/java`.
|
||||
|
||||
_For Gradle_: `build/generated/source/proto/main/grpc` and `build/generated/source/proto/main/java`)
|
||||
|
||||
You may need to instruct your IDE to mark them as source roots.
|
||||
In IntelliJ IDEA, right-click the folder, choose `Mark Directory As` -> `Generated Source Root`.
|
||||
Eclipse or VSCode will add them automatically for you.
|
||||
|
||||
Now you can implement a service based on the generated stubs:
|
||||
|
||||
@@ -112,7 +123,7 @@ Run the program in the usual way:
|
||||
or
|
||||
|
||||
```shell
|
||||
./gradle bootRun
|
||||
./gradlew bootRun
|
||||
```
|
||||
|
||||
You can try it out using a gRPC client like `grpcurl`:
|
||||
@@ -244,7 +255,7 @@ public class GrpcServerApplication {
|
||||
}
|
||||
```
|
||||
|
||||
Run it from your IDE, or on the command line with `mvn spring-boot:run` or `gradle bootRun`.
|
||||
Run it from your IDE, or on the command line with `./mvnw spring-boot:run` or `./gradlew bootRun`.
|
||||
|
||||
### gRPC Client
|
||||
|
||||
|
||||
@@ -13,12 +13,14 @@ Open it in your IDE in the usual way. E.g. if you're using IntelliJ IDEA: `idea
|
||||
|
||||
Define a `.proto` service definition file `src/main/proto/hello.proto` with the following contents:
|
||||
|
||||
IMPORTANT: Be sure to change the `java_package` to the one you chose in Spring Initializr
|
||||
|
||||
[source,proto]
|
||||
----
|
||||
syntax = "proto3";
|
||||
|
||||
option java_multiple_files = true;
|
||||
option java_package = "org.springframework.grpc.sample.proto";
|
||||
option java_package = "<your-package-name-goes-here>.proto";
|
||||
option java_outer_classname = "HelloWorldProto";
|
||||
|
||||
// The greeting service definition.
|
||||
@@ -53,7 +55,15 @@ or
|
||||
./gradlew build
|
||||
----
|
||||
|
||||
You'll get two new folders in the `target` directory (or `build` for Gradle): `target/target/generated-sources/protobuf/grpc-java` and `target/target/generated-sources/protobuf/java`. You may need to instruct your IDE to mark them as source roots. In IntelliJ IDEA, you'd right click the folder, choose `Mark Directory As` -> `Generated Source Root`. Eclipse or VSCode will add them automatically for you.
|
||||
Two new folders will be generated containing the source code for the stubs.
|
||||
|
||||
_For Maven_: `target/generated-sources/protobuf/grpc-java` and `target/generated-sources/protobuf/java`.
|
||||
|
||||
_For Gradle_: `build/generated/source/proto/main/grpc` and `build/generated/source/proto/main/java`)
|
||||
|
||||
You may need to instruct your IDE to mark them as source roots.
|
||||
In IntelliJ IDEA, right-click the folder, choose `Mark Directory As` -> `Generated Source Root`.
|
||||
Eclipse or VSCode will add them automatically for you.
|
||||
|
||||
Now you can implement a service based on the generated stubs:
|
||||
|
||||
@@ -110,7 +120,7 @@ or
|
||||
|
||||
[source,shell]
|
||||
----
|
||||
./gradle bootRun
|
||||
./gradlew bootRun
|
||||
----
|
||||
|
||||
You can try it out using a gRPC client like `grpcurl`:
|
||||
@@ -252,7 +262,7 @@ public class GrpcServerApplication {
|
||||
}
|
||||
----
|
||||
|
||||
Run it from your IDE, or on the command line with `mvn spring-boot:run` or `gradle bootRun`.
|
||||
Run it from your IDE, or on the command line with `./mvnw spring-boot:run` or `./gradlew bootRun`.
|
||||
|
||||
=== gRPC Client
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
|spring.grpc.client.channels | | Map of channels configured by name.
|
||||
|spring.grpc.client.default-channel.address | `+++static://localhost:9090+++` | The target address uri to connect to.
|
||||
|spring.grpc.client.default-channel.default-deadline | | The default deadline for RPCs performed on this channel.
|
||||
|spring.grpc.client.default-channel.default-load-balancing-policy | `+++round_robin+++` | The default load balancing policy the channel should use.
|
||||
|spring.grpc.client.default-channel.enable-keep-alive | `+++false+++` | Whether keep alive is enabled on the channel.
|
||||
|spring.grpc.client.default-channel.health.enabled | `+++false+++` | Whether to enable client-side health check for the channel.
|
||||
@@ -43,11 +44,11 @@
|
||||
|spring.grpc.server.port | `+++9090+++` | Server port to listen on. When the value is 0, a random available port is selected. The default is 9090.
|
||||
|spring.grpc.server.reflection.enabled | `+++true+++` | Whether to enable Reflection on the gRPC server.
|
||||
|spring.grpc.server.security.csrf.enabled | `+++false+++` | Whether to enable CSRF protection on gRPC requests.
|
||||
|spring.grpc.server.servlet.enabled | `+++true+++` | Whether to use a servlet server in a servlet-based web application. When the value is false, a native gRPC server will be forced.
|
||||
|spring.grpc.server.servlet.enabled | `+++true+++` | Whether to use a servlet server in a servlet-based web application. When the value is false, a native gRPC server will be created as long as one is available, and it will listen on its own port. Should only be needed if the GrpcServlet is on the classpath
|
||||
|spring.grpc.server.shutdown-grace-period | `+++30s+++` | Maximum time to wait for the server to gracefully shutdown. When the value is negative, the server waits forever. When the value is 0, the server will force shutdown immediately. The default is 30 seconds.
|
||||
|spring.grpc.server.ssl.bundle | | SSL bundle name.
|
||||
|spring.grpc.server.ssl.bundle | | SSL bundle name. Should match a bundle configured in spring.ssl.bundle.
|
||||
|spring.grpc.server.ssl.client-auth | `+++none+++` | Client authentication mode.
|
||||
|spring.grpc.server.ssl.enabled | | Whether to enable SSL support. Enabled automatically if "bundle" is provided unless specified otherwise.
|
||||
|spring.grpc.server.ssl.secure | `+++true+++` | Flag to indicate that client authentication is secure (i.e. certificates are checked). Do not set this to false in production.
|
||||
|
||||
|===
|
||||
|===
|
||||
Reference in New Issue
Block a user