我使用Gradle构建了一个jar文件。它从“gradle run”中运行得很好,但是当我在Eclipse中运行它时(Run-> External Tools-> External Tools Configurations),我在其中一个Spring类上得到了NoClassDefFoundError。Jar文件可以从Gradle Run运行,但在Eclipse中运行时得到NoClassDefFoundError
这是的build.gradle:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'
mainClassName = 'com.ii.mainClass'
repositories {
mavenCentral()
}
jar {
manifest {
attributes 'Main-Class': 'com.ii.mainClass'
}
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
dependencies {
compile 'com.fasterxml.jackson.core:jackson-annotations:2.6.1'
compile 'com.fasterxml.jackson.core:jackson-core:2.6.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.1'
compile 'org.springframework:spring-beans:4.2.0.RELEASE'
compile 'org.springframework:spring-context:4.2.0.RELEASE'
compile 'org.springframework:spring-core:4.2.0.RELEASE'
compile 'org.springframework:spring-expression:4.2.0.RELEASE'
compile 'org.springframework.xd:spring-xd-tuple:1.0.4.RELEASE'
}
我看着jar文件,它没有依赖罐子,这就是为什么我在Eclipse中运行时,得到NoClassDefinition错误。我也尝试过在本地添加这些jar,但是这并不能解决问题,有人可以让我知道如何在Eclipse中运行这个jar吗?
dependencies {
compile fileTree(dir: 'lib', include: ['*.jar'])
}