
Kotlin, Boot SpringでのBuildの失敗
概要
現在、Kotlin, Boot Springを入門中です。
そこで、参考書通りに作業を進めていたのですが、ビルド時にエラーが発生しました。
具体的には、localhostにアクセスするとコントローラで生成した値をHTMLで表示するシンプルな機能です。
恐らく参考書とのバージョンの違いだとは思うのですが…。
自分なりに解決方法を模索してみましたが、中々解決せず…。
どなたか解決方法のご教授お願い致します。
エラー内容
Execution failed for task ':bootRun'. > Process 'command '/Applications/IntelliJ IDEA Edu.app/Contents/jbr/Contents/Home/bin/java'' finished with non-zero exit value 1
該当のソースコード
Kotlin
1// Hello.kt 2 3package com.example.hello_app.demo 4 5import org.springframework.stereotype.Controller 6import org.springframework.ui.Model 7import org.springframework.web.bind.annotation.GetMapping 8 9@Controller 10class Hello { 11 @GetMapping("/") 12 fun index(model: Model): String { 13 model.addAttribute("Greeting", "Hello, World") 14 return "index" 15 } 16} 17
Kotlin
1// DemoApplication.kt 2 3package com.example.hello_app.demo 4 5import org.springframework.boot.autoconfigure.SpringBootApplication 6import org.springframework.boot.runApplication 7 8@SpringBootApplication 9class DemoApplication 10 11fun main(args: Array<String>) { 12 runApplication<DemoApplication>(*args) 13}
HTML
1// index.html 2 3<!DOCTYPE html> 4<html lang="ja" xmlns="http://www.w3.org/1999/xhtml" 5 xmlns:th="http://www.thymeleaf.org"> 6<head> 7 <meta charset="UTF-8"> 8 <title>Hello</title> 9</head> 10<body> 11 <h1>Spring Boot Hello World</h1> 12 <p> 13 <span th:text="${Greeting}"></span> 14 </p> 15</body> 16</html>
Groovy
1// build.gradle.kts 2 3import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 4 5plugins { 6 id("org.springframework.boot") version "2.2.2.RELEASE" 7 id("io.spring.dependency-management") version "1.0.8.RELEASE" 8 kotlin("jvm") version "1.3.61" 9 kotlin("plugin.spring") version "1.3.61" 10} 11 12group = "com.example.hello_app" 13version = "0.0.1-SNAPSHOT" 14java.sourceCompatibility = JavaVersion.VERSION_1_8 15 16repositories { 17 mavenCentral() 18} 19 20dependencies { 21 implementation("org.springframework.boot:spring-boot-starter-thymeleaf") 22 implementation("org.springframework.boot:spring-boot-starter-web") 23 implementation("com.fasterxml.jackson.module:jackson-module-kotlin") 24 implementation("org.jetbrains.kotlin:kotlin-reflect") 25 implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") 26 testImplementation("org.springframework.boot:spring-boot-starter-test") { 27 exclude(group = "org.junit.vintage", module = "junit-vintage-engine") 28 } 29} 30 31tasks.withType<Test> { 32 useJUnitPlatform() 33} 34 35tasks.withType<KotlinCompile> { 36 kotlinOptions { 37 freeCompilerArgs = listOf("-Xjsr305=strict") 38 jvmTarget = "1.8" 39 } 40} 41 42


回答1件
あなたの回答
tips
プレビュー