teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

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

2020/03/22 08:09

投稿

iMASAKI
iMASAKI

スコア12

title CHANGED
File without changes
body CHANGED
@@ -2,8 +2,15 @@
2
2
  IntelliJ IDEA(以降IDEAと言います)でKotlinファイルを編集すると以下のように下線を引かれてしまいます。
3
3
 
4
4
  ![画像1](09755d8a35ac3ecae3a23fdf76266a43.png)
5
+
6
+ ```Kotlin
7
+ fun main(args: Array<String>){
8
+ val word = "Hello"
9
+ val word2 = "World"
10
+ println(word == word2)
11
+ }
12
+ ```
5
13
  ![画像2](0db6f33c23dc5b9ef731b89407467cac.png)
6
-
7
14
  > 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
8
15
 
9
16
  # 環境
@@ -14,4 +21,45 @@
14
21
  # 補足
15
22
  新しい空のKotlinプロジェクトを作成した状態だと実行できませんが、
16
23
  KtorやSpringBootなどでプロジェクトを作成すると、下線が引かれますが実行できます。
17
- ![Ktorプロジェクト](8b1f7d6a25a999a72ce810d856ef36a0.png)
24
+ ![Ktorプロジェクト](8b1f7d6a25a999a72ce810d856ef36a0.png)
25
+
26
+ ```Kotlin
27
+ fun main(args: Array<String>){
28
+ io.ktor.server.netty.EngineMain.main(args)
29
+ val word = "Hello"
30
+ val word2 = "World"
31
+ println(word == word2)
32
+ }
33
+
34
+ data class Snippet(val text: String)
35
+
36
+ data class PostSnippet(val snippet: PostSnippet.Text) {
37
+ data class Text(val text: String)
38
+ }
39
+
40
+ val snippets = mutableListOf(
41
+ Snippet("hello"),
42
+ Snippet("world")
43
+ )
44
+
45
+ fun Application.module() {
46
+ install(ContentNegotiation){
47
+ jackson {
48
+ enable(SerializationFeature.INDENT_OUTPUT)
49
+ }
50
+
51
+ routing {
52
+ get("/snippets"){
53
+ // call.respondText("OK")
54
+ call.respond(mapOf("snippets" to synchronized(snippets){ snippets.toList()}))
55
+ }
56
+
57
+ post("/snippets"){
58
+ val post = call.receive<PostSnippet>()
59
+ snippets += Snippet(post.snippet.text)
60
+ call.respond(mapOf("OK" to true))
61
+ }
62
+ }
63
+ }
64
+ }
65
+ ```