Gradle projet, error NoSuchMethodException during deployment on heroku - spring

i'm trying to deploy a Spring boot project with gradle on heroku.
But during the deployment on Herku when the application tries to launch I get the following error:
2021-08-20T07:22:42.904392+00:00 heroku[web.1]: Starting process with command `java -Dserver.port=42904 $JAVA_OPTS -jar build/libs/api-gateway-0.0.1-SNAPSHOT.jar`
2021-08-20T07:22:44.675657+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2021-08-20T07:22:44.679643+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2021-08-20T07:22:44.990415+00:00 app[web.1]: Exception in thread "main" java.lang.NoSuchMethodException: com.abade.apigateway.ApiApplication.main([Ljava.lang.String;)
2021-08-20T07:22:44.990713+00:00 app[web.1]: at java.base/java.lang.Class.getDeclaredMethod(Class.java:2475)
2021-08-20T07:22:44.990742+00:00 app[web.1]: at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:47)
2021-08-20T07:22:44.990803+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
2021-08-20T07:22:44.990841+00:00 app[web.1]: at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
2021-08-20T07:22:44.990880+00:00 app[web.1]: at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
2021-08-20T07:22:45.062399+00:00 heroku[web.1]: Process exited with status 1
When I don't specify the main class in the gradle and the jar in the Procfile I get an error: no main manifest attribute.
This is my Procfile :
web: java -Dserver.port=$PORT $JAVA_OPTS -jar build/libs/api-gateway-0.0.1-SNAPSHOT.jar
And my build.gradle :
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.5.3"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
kotlin("jvm") version "1.4.32"
kotlin("plugin.spring") version "1.4.32"
}
group = "com.abade"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_11
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
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")
implementation("com.google.firebase:firebase-admin:8.0.0")
implementation("junit:junit:4.13.1")
implementation("org.modelmapper:modelmapper:2.3.3")
implementation ("io.springfox:springfox-boot-starter:3.0.0")
runtimeOnly("com.h2database:h2")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.mockito:mockito-core:3.+")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
springBoot {
mainClass.set("com.abade.apigateway.ApiApplication")
}
Do you have any suggestions ?

It tries to tell you, that com.abade.apigateway.ApiApplication lacks method main([Ljava.lang.String;) ...and therefore the main entry point is unknown.

Related

Unresolved symbol:mainClassName

I have a SpringBoot project with the following build.gradle:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.7.0"
id("io.spring.dependency-management") version "1.0.9.RELEASE"
kotlin("jvm") version "1.7.0"
kotlin("plugin.spring") version "1.7.0"
kotlin("plugin.jpa") version "1.6.21"
id("org.flywaydb.flyway") version "6.4.4"
}
group = "com.planes"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
}
dependencies {
implementation("org.apache.tomcat.embed:tomcat-embed-jasper")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-security")
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")
implementation("io.jsonwebtoken:jjwt:0.9.0")
implementation("org.postgresql:postgresql")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
testImplementation("org.springframework.security:spring-security-test")
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
springBoot {
mainClassName = "com.planes.planesserver.DemoApplication"
}
When I run the Gradle Wrapper Task I get the following error: "Unresolved reference: mainClassName"
This happens after I updated SpringBoot from Version 2.2 to 2.7 and gradle from version 5 to version 6.9.3
In the previous configuration the project could compile just fine. Are there any adjustments I need to still make for this new configuration ?
Can anyone please give a suggestion ?
In Springboot 2.4 they changed the name and type of the main classname property, see in Springboot 2.4 Release notes:
You need to update your build script as follows :
springBoot {
// before springboot 2.4
// mainClassName = "com.planes.planesserver.DemoApplication"
// since springboot 2.4 :
mainClass.set( "com.planes.planesserver.DemoApplication")
}

Spring boot with Kotlin and Gradle failing on Heroku: Error: Unable to access jarfile target/*.jar

I have looked for solutions for my problem for a while now, but I can't find anything that works. I am attempting to run my Spring Boot application made with Kotlin and Gradle on Heroku. Build is succeeding but when opening the app I get Application error. When running heroku logs --tail this the is error message I receive.
022-08-28T07:51:03.459300+00:00 heroku[web.1]: State changed from crashed to starting
2022-08-28T07:51:07.247014+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -jar target/*.jar`
2022-08-28T07:51:08.081732+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2022-08-28T07:51:08.083953+00:00 app[web.1]: Error: Unable to access jarfile target/*.jar
2022-08-28T07:51:08.258989+00:00 heroku[web.1]: Process exited with status 1
2022-08-28T07:51:08.322687+00:00 heroku[web.1]: State changed from starting to crashed
build.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.7.3"
id("io.spring.dependency-management") version "1.0.13.RELEASE"
kotlin("jvm") version "1.6.21"
kotlin("plugin.spring") version "1.6.21"
kotlin("plugin.jpa") version "1.6.21"
java
}
group = "no.haakon"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_17
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
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")
// TESTING
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.mockk:mockk:1.10.4")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "16"
}
}
springBoot {
mainClass.set("no.haakon.springdemo.SpringDemoApplicationKt")
}
tasks.withType<Test> {
useJUnitPlatform()
}
Procfile
web: java $JAVA_OPTS -jar target/*.jar
Any suggestions?

Dockerfile can not build jar file : Main class name has not been configured

I am building a dockerfile for a microservices architecture (spring) but I find some difficulties.
I got this error when buidling the boot jar
Main class name has not been configured and it could not be resolved
my dockerfile is
FROM gradle:6.5-jdk11 AS TEMP_BUILD_IMAGE
ENV APP_HOME=/usr/app/
WORKDIR $APP_HOME
COPY build.gradle.kts settings.gradle.kts $APP_HOME
COPY gradle $APP_HOME/gradle
COPY --chown=gradle:gradle . /home/gradle/src
USER root
RUN chown -R gradle /home/gradle/src
RUN gradle bootJar || return 0
COPY . .
RUN gradle clean bootJar
FROM openjdk:11-jdk
ENV ARTIFACT_NAME=app.jar
ENV APP_HOME=/usr/app/
WORKDIR $APP_HOME
COPY --from=TEMP_BUILD_IMAGE $APP_HOME/build/libs/$ARTIFACT_NAME .
ENTRYPOINT exec java -jar ${ARTIFACT_NAME}
The error is in 9th step
RUN gradle bootJar || return 0
I tried to put the name of the class in the gradle file, and i got this error
Exception in thread "main" java.lang.NoSuchMethodException: com.test.config.ConfigServerApp.main([Ljava.lang.String;)
this is my gradle file
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.tasks.bundling.BootJar
plugins {
id("io.spring.dependency-management") version "1.0.9.RELEASE"
id("org.springframework.boot") version "2.3.0.RELEASE"
kotlin("plugin.spring") version "1.3.72"
kotlin("jvm") version "1.3.72"
}
repositories {
mavenCentral()
}
group = "com.test"
version = "1.0.0"
java.sourceCompatibility = JavaVersion.VERSION_11
extra["springCloudVersion"] = "Hoxton.SR5"
dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.springframework.cloud:spring-cloud-config-server")
implementation("org.springframework.cloud:spring-cloud-config-monitor")
implementation("org.springframework.cloud:spring-cloud-starter-bus-amqp")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
}
dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-Xjsr305=strict")
}
}
tasks.withType<BootJar> {
archiveFileName.set("app.jar")
mainClassName = "com.test.config.ConfigServerApp"
}
this is my main class (i m using kotlin)
package com.test.config
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.cloud.config.server.EnableConfigServer
#EnableConfigServer
#SpringBootApplication
class ConfigServerApp
fun main(args : Array<String>)
{
runApplication<ConfigServerApp>(*args)
}
when I launch the application from my editor it works, but when I launch it from the jar file or from docker, it does not work
how can i fix this please?
Just to make a formal answer from my comment since it worked. As I explained in the comment: When we use Kotlin, the real main class is generated behind the scenes with Kt suffix, you should find it in your build folder after running gradle bootJar.
You should update the mainClassName to com.test.config.ConfigServerAppKt as shown below:
tasks.withType<BootJar> {
archiveFileName.set("app.jar")
mainClassName = "com.test.config.ConfigServerAppKt"
}
As explained in the Kotlin docs :
All the functions and properties declared in a file app.kt inside a package org.example, including extension functions, are compiled into static methods of a Java class named org.example.AppKt.
So your main method will be part of java class named ConfigServerAppKt after compilation. So you should change your mainClassName to com.test.config.ConfigServerAppKt.

Building an executable jar that can be published to maven local repo with `publishToMavenLocal` - spring boot project

Need help with building an executable jar (that can be run with java -jar app.jar) that can be published to maven local repo (using gradle publishToMavenLocal) for a spring boot project.
With these gradle settings gradle publishToMavenLocal works.
Gradle version is 6.3
Spring boot version is 2.2.6
Kotlin 1.3.71
parent build.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.6.RELEASE")
}
}
plugins {
id("org.springframework.boot") version "2.2.6.RELEASE" apply false
id("io.spring.dependency-management") version "1.0.9.RELEASE" apply false
kotlin("jvm") version "1.3.71" apply false
kotlin("plugin.spring") version "1.3.71" apply false
`maven-publish`
`java-library`
signing
}
allprojects {
group = "com.example.user"
version = "0.0.1-SNAPSHOT"
tasks.withType<JavaCompile> {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
incremental = false
}
}
}
subprojects {
repositories {
mavenLocal()
mavenCentral()
}
apply {
plugin("io.spring.dependency-management")
plugin("maven-publish")
}
}
sub-project build.gradle.kts:
plugins {
id("org.springframework.boot")
id("io.spring.dependency-management")
kotlin("jvm")
kotlin("plugin.spring")
}
val developmentOnly by configurations.creating
configurations {
runtimeClasspath {
extendsFrom(developmentOnly)
}
}
dependencies {
implementation(project(":common"))
implementation(project(":user-models"))
implementation(project(":user-core"))
implementation("org.springframework.boot:spring-boot-starter-webflux") {
exclude(group = "org.springframework.boot", module = "spring-boot-starter-logging")
}
implementation("org.springframework.boot:spring-boot-maven-plugin:2.2.6.RELEASE")
implementation(group = "org.springframework.boot", name = "spring-boot-autoconfigure", version = "2.2.6.RELEASE")
implementation(group = "org.springframework.boot", name = "spring-boot-starter-parent", version = "2.2.6.RELEASE")
implementation("org.springframework.boot:spring-boot-configuration-processor:2.2.6.RELEASE")
implementation("org.projectreactor:reactor-spring:1.0.1.RELEASE")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation(group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.3.5")
implementation(group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-reactor", version = "1.3.5")
implementation(group = "org.springframework.boot", name = "spring-boot-starter-log4j2", version = "2.2.6.RELEASE")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
developmentOnly("org.springframework.boot:spring-boot-devtools")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.jar {
enabled = true
manifest {
attributes["Main-Class"] = "com.subnub.user.service.ServiceApplicationKt"
attributes["Class-Path"] = configurations.compileClasspath.get().map { it.name }.joinToString(" ")
}
from(configurations.compileClasspath.get().map { if(it.isDirectory) it else zipTree(it) })
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
tasks.bootJar {
enabled = false
archiveClassifier.set("application")
mainClassName = "com.example.user.service.ServiceApplicationKt"
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
afterEvaluate {
artifactId = tasks.jar.get().archiveBaseName.get()
}
}
}
}
But the jar that is build with these gradle settings breaks when tried to run
stderr:
➜ example-user git:(master) ✗ java -jar example-service/build/libs/example-service-0.0.1-SNAPSHOT.jar
[INFO ] 2020-04-25 22:18:11.871 [main] ServiceApplicationKt - Starting ServiceApplicationKt on admins-mbp-7 with PID 4663 (/Users/zerocase/personal/startups/example/code/example-user/example-service/build/libs/example-service-0.0.1-SNAPSHOT.jar started by abhishek in /Users/zerocase/personal/startups/example/code/example-user)
[INFO ] 2020-04-25 22:18:11.874 [main] ServiceApplicationKt - No active profile set, falling back to default profiles: default
[ERROR] 2020-04-25 22:18:12.055 [main] SpringApplication - Application run failed
java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
at org.springframework.util.Assert.notEmpty(Assert.java:464) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:173) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getAutoConfigurationEntry(AutoConfigurationImportSelector.java:116) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:396) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:878) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:808) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:779) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:192) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:319) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66) ~[example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [example-service-0.0.1-SNAPSHOT.jar:?]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [example-service-0.0.1-SNAPSHOT.jar:?]
at com.example.user.service.ServiceApplicationKt.main(ServiceApplication.kt:19) [example-service-0.0.1-SNAPSHOT.jar:?]
I've tried the workaround suggested here (https://docs.gradle.org/current/userguide/upgrading_version_6.html#publishing_spring_boot_applications) for publishing bootJar artifact. The jar works fine in this case but,
configurations {
listOf(apiElements, runtimeElements).forEach {
it.get().outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(tasks.jar) }
it.get().outgoing.artifact(tasks.bootJar)
}
}
but then gradle does not allows me to do gradle pTML
➜ example-user git:(master) ✗ gradle pTML
> Task :user-service:publishMavenJavaPublicationToMavenLocal FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':user-service:publishMavenJavaPublicationToMavenLocal'.
> Failed to publish publication 'mavenJava' to repository 'mavenLocal'
> Artifact example-service-0.0.1-SNAPSHOT.jar wasn't produced by this build.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
16 actionable tasks: 3 executed, 13 up-to-date
Figured out the fix, artifact needed to be defined in the the publications scope.
publishing {
publications {
create<MavenPublication>("mavenJava") {
//from(components["java"]) // <-- this is not required
artifact(tasks.bootJar.get()) // <-- this is required
}
}
}
and slight modified configurations scope (ref):
configurations {
listOf(apiElements, runtimeElements).forEach {
// Method #1
val jar by tasks
it.get().outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
// Method #2
it.get().outgoing.artifact(tasks.bootJar)
}
}
Here are some sample implementations of publishing publications.
I fixed the error Artifact ....jar wasn't produced by this build adding the parameter enabled = true to the jar task
jar {
enabled = true
}

Failed to configure a DataSource: 'url' attribute is not specified

I'm new at spring boot with kotlin.
I have error when application start up.
I had been seeking various solutions in the other answers in Stackoverflow.
But no answers gave me no solutions.
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
My application.properties configuration is following.
spring.datasource.url=jdbc:mysql://localhost/db_name
spring.datasource.username=db_user
spring.datasource.password=db_pass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
And build.gradle.kts is following.
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.2.0.RELEASE"
id("io.spring.dependency-management") version "1.0.8.RELEASE"
war
kotlin("jvm") version "1.3.50"
kotlin("plugin.spring") version "1.3.50"
kotlin("plugin.jpa") version "1.3.50"
}
group = "jp.co.blowfish.springboot"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
val developmentOnly by configurations.creating
configurations {
runtimeClasspath {
extendsFrom(developmentOnly)
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
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("mysql:mysql-connector-java")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
I have no idea what is wrong.
It is missing the port of Mysql by default is 3306
spring.datasource.url=jdbc:mysql://localhost:3306/db_name`
or application.properties is in resources folder.

Resources