実現したいこと
kotlinとspringbootを使ってローカル環境でアプリを起動させたいです。
前提
springbootを初めて使います。というかWeb領域が初めてです。サイトを見ながらspringbootでHello Worldを返すだけのアプリをチュートリアルで書きました。
しかし、mainから起動してみると、「Web application could not be started as there was no org.springframework.boot.web.servlet.server.ServletWebServerFactory bean defined in the context.
Action:
Check your application's dependencies for a supported servlet web server.
Check the configured web application type.
ターゲット VM から切断されました。アドレス: '..........'、トランスポート: 'ソケット'
プロセスは終了コード 1 で終了しました」
というメッセージが表示されて、起動が終了してしまいます。そのため、ローカル環境で実行ができません。コードはサイトをそのまままねしたもので、エラーは出ていません。
まねているサイトは「https://zenn.dev/msksgm/books/implementing-server-side-kotlin-development/viewer/chapter-02-02-spring-intro-hello-world」です。
情報が少ないですが、もし原因がわかる方がいらっしゃいましたらアドバイスをいただけるとありがたいです。
該当のソースコード
kotlin
1package com.example.springboot 2 3import org.springframework.boot.autoconfigure.SpringBootApplication 4import org.springframework.boot.runApplication 5 6@SpringBootApplication7class SpringBootApplication 8 9fun main(args: Array<String>) {10 runApplication<SpringBootApplication>(*args)11}12
kotlin
1package com.example.springboot.controller 2 3import org.springframework.stereotype.Controller 4import org.springframework.web.bind.annotation.GetMapping 5 6@Controller7class MainController {8 @GetMapping("/")9 fun hellWorld(): String {10 return "hello world"11 }12}
試したこと
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
0 コメント