我有一个简单的gradle文件,我可以从中创建一个jar文件
当我运行jar文件但是我得到并且错误:'线程中的异常“main”java.lang.NoClassDefFoundError:scala / Predef $'
build.gradle看起来像这样:
apply plugin: 'scala'
apply plugin: 'distribution'
def mainClass = "com.domain.Hello"
distributions {
custom {}
}
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.scala-lang', name: 'scala-library', version: '2.11.4'
}
jar {
manifest {
attributes 'Main-Class': mainClass
}
}
task run(type: JavaExec, description: "Runs the project") {
main = mainClass
classpath sourceSets.main.runtimeClasspath
classpath configurations.runtime
}
答案 0 :(得分:0)
您需要包含'' scala-compile'在' scala-library'
旁边打包答案 1 :(得分:0)
运行jar时,需要在类路径中包含scala-library,如此
scala -cp [scala library jar] [project jar]
如果您不想这样做,请查看此博文http://blogs.steeplesoft.com/posts/2013/09/04/building-fat-jars-with-gradle/