Skip to content

Commit e73cd61

Browse files
committed
Tidy up README
1 parent 780f8e6 commit e73cd61

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

spring-grpc-docs/src/main/antora/modules/ROOT/pages/getting-started.adoc

+25-10
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33

44
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. https://github.com/spring-projects-experimental/spring-grpc/tree/main/samples/grpc-server[`grpc-server`]). You can run it with `mvn spring-boot:run` or `gradle bootRun`. You will see the following code in that sample.
55

6-
Want to get started? Let's speedrun a working service. Go to the [Spring Initializr](https://start.spring.io), select `gRPC`, `Web`, and `GraalVM`. I'll be using Apache Maven in this tutorial but Gradle works, too.
6+
Want to get started? Let's speedrun a working service. Go to the [Spring Initializr](https://start.spring.io), select `gRPC`, `Web`, and `GraalVM`. Both Apache Maven and Gradle should work. Download the `.zip` file and unzip it. Open it in your IDE in the usual way. E.g. if you're using IntelliJ IDEA: `idea pom.xml`; or for VSCode `code .`.
77

8-
If you want to use GraalVM native images, make sure you have the GraalVM distribution of OpenJDK installed. You can do so with [sdkman.io](https://sdkman.io). e.g.: `sdk install java 23.0.1-graalce && sdk default java 23.0.1-graalce`.
9-
10-
Download the `.zip` file and unzip it. Open it in your IDE in the usual way. If you're using IntelliJ IDEA: `idea pom.xml`.
11-
12-
Define a `.proto` service definition:
8+
Define a `.proto` service definition file `src/main/proto/hello.proto` with the following contents:
139

1410
[source,proto]
1511
----
@@ -45,7 +41,14 @@ We'll want to define the stubs for a Java service based on this definition:
4541
./mvnw clean package
4642
----
4743

48-
You'll get two new folders in the `target` directory: `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`.
44+
or
45+
46+
[source,shell]
47+
----
48+
./gradlew build
49+
----
50+
51+
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.
4952

5053
Now you can implement a service based on the generated stubs:
5154

@@ -98,14 +101,21 @@ Run the program in the usual way:
98101
./mvnw spring-boot:run
99102
----
100103

104+
or
105+
106+
[source,shell]
107+
----
108+
./gradle bootRun
109+
----
110+
101111
You can try it out using a gRPC client like `grpcurl`:
102112

103113
[source,shell]
104114
----
105115
grpcurl -d '{"name":"Hi"}' -plaintext localhost:9090 Simple.SayHello
106116
----
107117

108-
You should get a response like:
118+
You should get a response like this:
109119

110120
[source,shell]
111121
----
@@ -114,7 +124,8 @@ You should get a response like:
114124
}
115125
----
116126

117-
Want some more details on what's happening? Read on!
127+
More details on what is going on in the next section.
128+
118129

119130
== Details
120131

@@ -262,4 +273,8 @@ then in `application.properties`:
262273
spring.grpc.client.channels.local.address=0.0.0.0:9090
263274
----
264275

265-
There is a default named channel (named "default") that you can configure in the same way, and then it will be used by default if there is no channel with the name specified in the channel creation.
276+
There is a default named channel (named "default") that you can configure in the same way, and then it will be used by default if there is no channel with the name specified in the channel creation.
277+
278+
=== Native Images
279+
280+
Native images are supported for gRPC servers and clients. You can build in the https://docs.spring.io/spring-boot/how-to/native-image/developing-your-first-application.html[normal Spring Boot] way for your build tool (Maven or Gradle).

0 commit comments

Comments
 (0)