我正在尝试构建Kotlin应用程序,但是即使构建成功,我仍然会遇到以下错误。我在做什么错了?
▶ java -jar build/libs/app-0.1.jar
22:10:02.122 [main] INFO io.micronaut.runtime.Micronaut - No embedded container found. Running as CLI application
这是我的构建状态:
▶ ./gradlew assemble
BUILD SUCCESSFUL in 3s
14 actionable tasks: 1 executed, 13 up-to-date
那是我的gradle.build文件的一部分:
apply from: "dependencies.gradle"
apply from: "protobuf.gradle"
version "0.1"
group "app"
mainClassName = "app.Application"
dependencies {
compile "ch.qos.logback:logback-classic:1.2.3"
}
jar {
manifest {
attributes "Main-Class": mainClassName
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
答案 0 :(得分:0)
很难看清楚没有看到项目的情况,但是可能导致该问题的一件事就是不依赖io.micronaut:micronaut-http-server-netty
。新创建的应用在build.gradle
中将具有类似的内容...
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}"
compile "org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}"
compile "io.micronaut:micronaut-runtime"
compile "io.micronaut:micronaut-http-client"
// Make Sure You Have This...
compile "io.micronaut:micronaut-http-server-netty"
kapt "io.micronaut:micronaut-inject-java"
kapt "io.micronaut:micronaut-validation"
kaptTest "io.micronaut:micronaut-inject-java"
runtime "ch.qos.logback:logback-classic:1.2.3"
runtime "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.4.1"
testCompile "org.junit.jupiter:junit-jupiter-api:5.1.0"
testCompile "org.jetbrains.spek:spek-api:1.1.5"
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.1.0"
testRuntime "org.jetbrains.spek:spek-junit-platform-engine:1.1.5"
}
答案 1 :(得分:0)
我有一个类似的问题:
compile 'io.micronaut:micronaut-http-server-netty:1.1.0'
中有build.gradle
。我还使用了shadowJar
插件,这就是问题所在。添加:
shadowJar {
mergeServiceFiles()
}
解决了问题。它将META-INF/services
资源中的条目转换为单个资源。我阴影遮盖的jar
文件在此文件夹中包含很多条目。