So I've been playing around with spring boot for the first time and it works wonderfully, except I can't figure out how to build a .war file to deploy to my personal server. I've read a dozen or more blogs documentation on the Spring website but I just don't get how to build the .war.
I'm using intellij, kotlin, and gradle. Any help pointing me in the right direction would be greatly appreciated.
Here is what my gradle file looks like:
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.tasks.bundling.BootJar
import org.springframework.boot.gradle.tasks.bundling.BootWar
plugins {
kotlin("plugin.jpa") version "1.2.71"
id("org.springframework.boot") version "2.1.6.RELEASE"
id("io.spring.dependency-management") version "1.0.7.RELEASE"
kotlin("jvm") version "1.2.71"
kotlin("plugin.spring") version "1.2.71"
war
}
apply(plugin = "io.spring.dependency-management")
the<DependencyManagementExtension>().apply {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}
}
. . . .
dependencies {
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-mustache")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
developmentOnly("org.springframework.boot:spring-boot-devtools")
runtimeOnly("com.h2database:h2")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.getByName<Jar>("jar") {
enabled = true
}
tasks.getByName<War>("war") {
enabled = true
}
tasks.getByName<BootJar>("bootJar") {
classifier = "boot"
mainClassName = "com.daniel.we_adventurers"
launchScript()
manifest {
attributes("Start-Class" to "com.daniel.we_adventurersn")
}
}
tasks.getByName<BootWar>("bootWar") {
classifier = "boot2"
mainClassName = "com.daniel.we_adventurers"
launchScript()
manifest {
attributes("Start-Class" to "com.daniel.we_adventurers")
attributes("Main-Class" to "org.springframework.boot.loader.PropertiesLauncher")
}
}
}