Polish "Improve Gradle instructions in README.md"

- Makes all Maven and Gradle commands use the wrappers
- Corrects the generated paths for Maven
- Moves note about package name up to admonition

Signed-off-by: Chris Bono <chris.bono@gmail.com>
This commit is contained in:
Chris Bono
2025-05-26 13:33:29 -05:00
parent da5b55cbe3
commit 09100d2c96

View File

@@ -9,7 +9,7 @@ For further information go to our [Spring gRPC reference documentation](https://
# Getting Started
This section offers jumping off points for how to get started using Spring gRPC. There is a simple sample project in the `samples` directory (e.g. [`grpc-server`](https://github.com/spring-projects/spring-grpc/tree/main/samples/grpc-server)). You can run it with `mvn spring-boot:run` or `gradle bootRun`. You will see the following code in that sample.
This section offers jumping off points for how to get started using Spring gRPC. There is a simple sample project in the `samples` directory (e.g. [`grpc-server`](https://github.com/spring-projects/spring-grpc/tree/main/samples/grpc-server)). You can run it with `./mvnw spring-boot:run` or `./gradlew bootRun`. You will see the following code in that sample.
Want to get started? Lets speedrun a working service.
@@ -21,11 +21,13 @@ Open it in your IDE in the usual way. E.g. if youre 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"; // !IMP: change the package name to the one you mentioned in spring initilizr
option java_package = "<your-package-name-goes-here>.proto";
option java_outer_classname = "HelloWorldProto";
// The greeting service definition.
@@ -58,9 +60,15 @@ or
./gradlew build
```
Youll get two new folders in the `target` directory: `target/target/generated-sources/protobuf/grpc-java` and `target/target/generated-sources/protobuf/java`.
(_For gradle_, refer the `build` directory: `build/generated/source/proto/main/grpc` & `build/generated/source/proto/main/java`)
You may need to instruct your IDE to mark them as source roots. In IntelliJ IDEA, youd 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:
@@ -246,7 +254,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