我的项目
gradle/kotlin
目录结构遵循默认/推荐的方法:
MYPROJ
/src/main/kotlin
app/OnsetsWebapp.kt
这是
build.gradle.kts
:我们指定的通知
mainClassName = app.OnsetsWebapp
:
plugins {
application
kotlin("jvm") version "1.3.71"
}
application {
mainClassName = "app.OnsetsWebapp"
}
dependencies {
compile(kotlin("stdlib"))
compile("org.slf4j:slf4j-simple:1.7.25")
compile("io.javalin:javalin:3.8.0")
compile("org.json:json:20160810")
compile("com.j2html:j2html:1.3.0")
}
repositories {
jcenter()
}
让我们构建它:
./gradlew build
BUILD SUCCESSFUL in 1s
8 actionable tasks: 5 executed, 3 up-to-date
现在让我们运行它:
$./gradlew run
这导致
> Task :run FAILED
Error: Could not find or load main class app.OnsetsWebapp
Caused by: java.lang.ClassNotFoundException: app.OnsetsWebapp
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':run'.
> Process 'command '/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
* 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 0s
4 actionable tasks: 1 executed, 3 up-to-date
那么为什么这个班
app.OnsetsWebapp
未找到?