質問編集履歴

1

ソースコードを追加しました。

2020/03/22 08:09

投稿

iMASAKI
iMASAKI

スコア12

test CHANGED
File without changes
test CHANGED
@@ -6,9 +6,23 @@
6
6
 
7
7
  ![画像1](09755d8a35ac3ecae3a23fdf76266a43.png)
8
8
 
9
- ![画像2](0db6f33c23dc5b9ef731b89407467cac.png)
10
9
 
11
10
 
11
+ ```Kotlin
12
+
13
+ fun main(args: Array<String>){
14
+
15
+ val word = "Hello"
16
+
17
+ val word2 = "World"
18
+
19
+ println(word == word2)
20
+
21
+ }
22
+
23
+ ```
24
+
25
+ ![画像2](0db6f33c23dc5b9ef731b89407467cac.png)
12
26
 
13
27
  > Error:(33, 13) Cannot access 'java.io.Serializable' which is a supertype of 'com.fasterxml.jackson.databind.ObjectMapper'. Check your module classpath for missing or conflicting dependencies
14
28
 
@@ -31,3 +45,85 @@
31
45
  KtorやSpringBootなどでプロジェクトを作成すると、下線が引かれますが実行できます。
32
46
 
33
47
  ![Ktorプロジェクト](8b1f7d6a25a999a72ce810d856ef36a0.png)
48
+
49
+
50
+
51
+ ```Kotlin
52
+
53
+ fun main(args: Array<String>){
54
+
55
+ io.ktor.server.netty.EngineMain.main(args)
56
+
57
+ val word = "Hello"
58
+
59
+ val word2 = "World"
60
+
61
+ println(word == word2)
62
+
63
+ }
64
+
65
+
66
+
67
+ data class Snippet(val text: String)
68
+
69
+
70
+
71
+ data class PostSnippet(val snippet: PostSnippet.Text) {
72
+
73
+ data class Text(val text: String)
74
+
75
+ }
76
+
77
+
78
+
79
+ val snippets = mutableListOf(
80
+
81
+ Snippet("hello"),
82
+
83
+ Snippet("world")
84
+
85
+ )
86
+
87
+
88
+
89
+ fun Application.module() {
90
+
91
+ install(ContentNegotiation){
92
+
93
+ jackson {
94
+
95
+ enable(SerializationFeature.INDENT_OUTPUT)
96
+
97
+ }
98
+
99
+
100
+
101
+ routing {
102
+
103
+ get("/snippets"){
104
+
105
+ // call.respondText("OK")
106
+
107
+ call.respond(mapOf("snippets" to synchronized(snippets){ snippets.toList()}))
108
+
109
+ }
110
+
111
+
112
+
113
+ post("/snippets"){
114
+
115
+ val post = call.receive<PostSnippet>()
116
+
117
+ snippets += Snippet(post.snippet.text)
118
+
119
+ call.respond(mapOf("OK" to true))
120
+
121
+ }
122
+
123
+ }
124
+
125
+ }
126
+
127
+ }
128
+
129
+ ```