You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
freeCompilerArgs.addAll("-Xjsr305=strict") // `-Xjsr305=strict` enables the strict mode for JSR-305 annotations
126
+
freeCompilerArgs.addAll("-Xjsr305=strict", "-Xannotation-default-target=param-property") // `-Xjsr305=strict` enables the strict mode for JSR-305 annotations
125
127
}
126
128
}
127
129
@@ -134,13 +136,15 @@ As you can see, there are a few Kotlin-related artifacts added to the Gradle bui
134
136
135
137
1. In the `plugins` block, there are two Kotlin artifacts:
136
138
137
-
*`kotlin("jvm")` – the plugin defines the version of Kotlin to be used in the project
138
-
*`kotlin("plugin.spring")` – Kotlin Spring compiler plugin for adding the `open` modifier to Kotlin classes in order to make them compatible with Spring Framework features
139
+
* The `kotlin("jvm")` plugin defines the version of Kotlin to be used in the project.
140
+
* The Kotlin Spring compiler plugin, `kotlin("plugin.spring")`, adds the `open` modifier to Kotlin classes to make
141
+
them compatible with Spring Framework features
139
142
140
-
2. In the `dependencies` block, a few Kotlin-related modules listed:
143
+
2. In the `dependencies` block, a few Kotlin-related modules are listed:
141
144
142
-
*`com.fasterxml.jackson.module:jackson-module-kotlin` – the module adds support for serialization and deserialization of Kotlin classes and data classes
* The `tools.jackson.module:jackson-module-kotlin` module adds support for serialization and deserialization of Kotlin
146
+
classes and data classes.
147
+
*`org.jetbrains.kotlin:kotlin-reflect` is a Kotlin reflection library that enables full support of the [reflection features](reflection.md).
144
148
145
149
3. After the dependencies section, you can see the `kotlin` plugin configuration block.
146
150
This is where you can add extra arguments to the compiler to enable or disable various language features.
@@ -172,8 +176,8 @@ fun main(args: Array<String>) {
172
176
<p>In Kotlin, if a class doesn't include any members (properties or functions), you can omit the class body (<code>{}</code>) for good.</p>
173
177
</def>
174
178
<deftitle="@SpringBootApplication annotation">
175
-
<p><a href="https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.using-the-springbootapplication-annotation"><code>@SpringBootApplication annotation</code></a> is a convenience annotation in a Spring Boot application.
176
-
It enables Spring Boot's <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.auto-configuration">auto-configuration</a>, <a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/ComponentScan.html">component scan</a>, and be able to define an extra configuration on their "application class".
179
+
<p><a href="https://docs.spring.io/spring-boot/reference/using/using-the-springbootapplication-annotation.html#using.using-the-springbootapplication-annotation"><code>@SpringBootApplication annotation</code></a> is a convenience annotation in a Spring Boot application.
180
+
It enables Spring Boot's <a href="https://docs.spring.io/spring-boot/reference/using/auto-configuration.html#using.auto-configuration">auto-configuration</a>, <a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/ComponentScan.html">component scan</a>, and be able to define an extra configuration on their "application class".
177
181
</p>
178
182
</def>
179
183
<deftitle="Program entry point – main()">
@@ -192,7 +196,6 @@ fun main(args: Array<String>) {
192
196
</def>
193
197
</deflist>
194
198
195
-
196
199
## Create a controller
197
200
198
201
The application is ready to run, but let's update its logic first.
@@ -253,7 +256,7 @@ The Spring application is now ready to run:
253
256
254
257
1. In the `DemoApplication.kt` file, click the green **Run** icon in the gutter beside the `main()` method:
255
258
256
-
{width=706}
259
+
{width=700}
257
260
258
261
> You can also run the `./gradlew bootRun` command in the terminal.
259
262
>
@@ -269,7 +272,7 @@ The Spring application is now ready to run:
269
272
270
273
You should see "Hello, John!" printed as a response:
Copy file name to clipboardExpand all lines: docs/topics/jvm/jvm-spring-boot-add-data-class.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,9 +84,9 @@ It requires changing the `MessageController` class to respond with a JSON docume
84
84
</list>
85
85
<p>The corresponding factory functions are also provided by the KotlinStandardLibrary to create instances of such collections.
86
86
</p>
87
-
<p>Inthis tutorial, you use the <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/list-of.html"><code>listOf()</code></a> function to create a list of <code>Message</code> objects.
87
+
<p>Inthis tutorial, you use the <a href="https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/list-of.html"><code>listOf()</code></a> function to create a list of <code>Message</code> objects.
88
88
Thisis the factory function to create a <i>read-only</i> list of objects: you can't add or remove elements from the list.<br/>
89
-
If it is required to perform write operations on the list, call the <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/mutable-list-of.html"><code>mutableListOf()</code></a> function to create a mutable list instance.
89
+
If it is required to perform write operations on the list, call the <a href="https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/mutable-list-of.html"><code>mutableListOf()</code></a> function to create a mutable list instance.
90
90
</p>
91
91
</def>
92
92
<def title="Trailing comma">
@@ -102,8 +102,8 @@ It requires changing the `MessageController` class to respond with a JSON docume
102
102
103
103
The response from `MessageController` will now be a JSON document containing a collection of `Message` objects.
104
104
105
-
> Any controller in the Spring application renders JSON response by default if Jackson library is on the classpath.
106
-
> As you [specified the `spring-boot-starter-web` dependency in the `build.gradle.kts` file](jvm-create-project-with-spring-boot.md#explore-the-project-gradle-build-file), you received Jackson as a _transitive_ dependency.
105
+
> Any controller in the Spring application renders a JSON response by default if the Jackson library is on the classpath.
106
+
> As you [specified the `spring-boot-starter-webmvc` dependency in the `build.gradle.kts` file](jvm-create-project-with-spring-boot.md#explore-the-project-gradle-build-file), you received Jackson as a _transitive_ dependency.
107
107
> Hence, the application responds with a JSON document if the endpoint returns a data structure that can be serialized to JSON.
108
108
>
109
109
{style="note"}
@@ -169,10 +169,10 @@ The Spring application is ready to run:
169
169
170
170
You will see a page with a collection of messages in JSON format:
171
171
172
-
{width=800}
172
+
{width=700}
173
173
174
174
## Next step
175
175
176
-
In the next part of the tutorial, you'll add and configure a database to your project,and make HTTP requests.
176
+
In the next part of the tutorial, you'll add and configure a database to your project and make HTTP requests.
177
177
178
178
**[Proceed to the next chapter](jvm-spring-boot-add-db-support.md)**
0 commit comments