@@ -90,13 +90,18 @@ The `id` field is a unique identifier for the greeting, and `content` is the tex
9090representation of the greeting.
9191
9292To model the greeting representation, create a resource representation class. To do so,
93- provide a Java record class for the `id` and `content` data, as the following listing (from
94- `src/main/java/com/example/restservice/Greeting.java`) shows:
93+ provide a Java record class or a Kotlin data class for the `id` and `content` data, as the following listing shows:
9594
96- [source,java]
95+ [source,java,indent=0,subs="verbatim,quotes",role="primary"]
96+ .Java
9797----
9898include::complete/src/main/java/com/example/restservice/Greeting.java[]
9999----
100+ [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
101+ .Kotlin
102+ ----
103+ include::complete-kotlin/src/main/kotlin/com/example/restservice/Greeting.kt[]
104+ ----
100105
101106====
102107NOTE: This application uses the https://github.com/FasterXML/jackson[Jackson JSON] library to
@@ -108,16 +113,19 @@ automatically marshal instances of type `Greeting` into JSON. Jackson is include
108113In Spring's approach to building RESTful web services, HTTP requests are handled by a
109114controller. These components are identified by the
110115https://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/web/bind/annotation/RestController.html[`@RestController`]
111- annotation, and the `GreetingController` shown in the following listing (from
112- `src/main/java/com/example/restservice/GreetingController.java`) handles `GET` requests
116+ annotation, and the `GreetingController` class shown in the following listing handles `GET` requests
113117for `/greeting` by returning a new instance of the `Greeting` class:
114118
115- ====
116- [source,java]
119+ [source,java,indent=0,subs="verbatim,quotes",role="primary"]
120+ .Java
117121----
118122include::complete/src/main/java/com/example/restservice/GreetingController.java[]
119123----
120- ====
124+ [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
125+ .Kotlin
126+ ----
127+ include::complete-kotlin/src/main/kotlin/com/example/restservice/GreetingController.kt[]
128+ ----
121129
122130This controller is concise and simple, but there is plenty going on under the hood. We
123131break it down step by step.
@@ -155,16 +163,18 @@ is automatically chosen to convert the `Greeting` instance to JSON.
155163== Run the Service
156164
157165The Spring Initializr creates an application class for you. In this case, you do not need
158- to further modify the class. The following listing
159- (from src/main/java/com/example/restservice/RestServiceApplication.java) shows the
160- application class:
166+ to further modify the class. The following listing shows the `RestServiceApplication` application class:
161167
162- ====
163- [source,java]
168+ [source,java,indent=0,subs="verbatim,quotes",role="primary"]
169+ .Java
164170----
165171include::complete/src/main/java/com/example/restservice/RestServiceApplication.java[]
166172----
167- ====
173+ [source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
174+ .Kotlin
175+ ----
176+ include::complete-kotlin/src/main/kotlin/com/example/restservice/RestServiceApplication.kt[]
177+ ----
168178
169179include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/main/spring-boot-application-new-path.adoc[]
170180
0 commit comments