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
The tutorial shows you how to build a simple chat application using Spring Boot and Kotlin. You will learn about the benefits of using Kotlin for server-side development from a syntax perspective.
@@ -31,11 +32,11 @@ This project is based on Spring Boot 2.4.0, which requires Kotlin 1.4.10. Make s
31
32
32
33
Clone the repository from IntelliJ IDEA by choosing `File | New | Project from Version Control`.
33
34
34
-
image::./images/download-from-vcs.png[]
35
+
image::{images}/download-from-vcs.png[]
35
36
36
37
Specify the project path: http://github.com/kotlin-hands-on/kotlin-spring-chat.
37
38
38
-
image::./images/download-from-vcs-github.png[]
39
+
image::{images}/download-from-vcs-github.png[]
39
40
40
41
Once you clone the project, IntelliJ IDEA will import and open it automatically.
41
42
Alternatively, you can clone the project with the command line:
Note that the project includes solution branches for each part of the tutorial. You can browse all the branches in the IDE by invoking the Branches action:
49
50
50
-
image::./images/intellij-git-branches.png[]
51
+
image::{images}/intellij-git-branches.png[]
51
52
52
53
Or you can use the command line:
53
54
@@ -56,36 +57,36 @@ git branch -a
56
57
57
58
It is possible to use the `Compare with branch` command in IntelliJ IDEA to compare your solution with the proposed one.
This should help you in the event that you have any trouble with the instructions at any stage of the tutorial.
70
71
71
72
=== Launching the application
72
73
The `main` method for the application is located in the `ChatKotlinApplication.kt` file. Simply click on the gutter icon next to the main method or hit the `Alt+Enter` shortcut to invoke the launch menu in IntelliJ IDEA:
73
74
74
-
image::./images/intellij-run-app-from-main.png[]
75
+
image::{images}/intellij-run-app-from-main.png[]
75
76
76
77
Alternatively, you can run the `./gradlew bootRun` command in the terminal.
77
78
78
79
Once the application starts, open the following URL: http://localhost:8080. You will see a chat page with a collection of messages.
79
80
80
-
image::./images/chat.gif[]
81
+
image::{images}/chat.gif[]
81
82
82
83
In the following step, we will demonstrate how to integrate our application with a real database to store the messages.
83
84
84
85
=== Project overview
85
86
86
87
Let's take a look at the general application overview. In this tutorial, we are going to build a simple chat application that has the following architecture:
87
88
88
-
image::./images/application-architecture.png[]
89
+
image::{images}/application-architecture.png[]
89
90
90
91
Our application is an ordinary 3-tier web application. The client facing tier is implemented by the `HtmlController` and `MessagesResource` classes. The application makes use of server-side rendering via the _Thymeleaf_ template engine and is served by `HtmlController`. The message data API is provided by `MessagesResource`, which connects to the service layer.
91
92
@@ -98,7 +99,7 @@ The `PersistentMessageService` connects to a database to store the messages. We
98
99
99
100
After you have downloaded the project sources and opened them in the IDE, you will see the following structure, which includes the classes mentioned above.
100
101
101
-
image::./images/project-tree.png[]
102
+
image::{images}/project-tree.png[]
102
103
103
104
104
105
Under the `main/kotlin` folder there are packages and classes that belong to the application. In that folder, we are going to add more classes and make changes to the existing code to evolve the application.
⚠️ To refresh the list of the project dependencies, click on the little elephant icon that appears in the top right-hand corner of the editor.
289
290
290
-
image::./images/intellij-gradle-reload.png[]
291
+
image::{images}/intellij-gradle-reload.png[]
291
292
292
293
=== Create database schema and configuration
293
294
@@ -307,7 +308,7 @@ CREATE TABLE IF NOT EXISTS messages (
307
308
308
309
⌨️ Create a new folder called `sql` in the `src/main/resources` directory. Then put the SQL code from above into the `src/main/resources/sql/schema.sql` file.
309
310
310
-
image::./images/schema-sql-location.png[]
311
+
image::{images}/schema-sql-location.png[]
311
312
312
313
Also, you should modify `application.properties` so it contains the following attributes:
313
314
@@ -607,7 +608,7 @@ The test above looks similar to the previous one, except we check that the poste
607
608
608
609
Once we have implemented all these tests, we can run them and see whether they pass.
609
610
610
-
image::./images/intellij-running-tests.png[]
611
+
image::{images}/intellij-running-tests.png[]
611
612
612
613
At this stage, we added message persistence to our chat application. The messages can now be delivered to all active clients that connect to the application. Additionally, we can now access the historical data, so everyone can read previous messages if they need to.
0 commit comments