我使用 gradle 作为 JavaFX 插件。即使在distribution/构建和运行可执行文件之后,一切都可以完美运行,除了一个类:CloseableHttpClient
出于多种目的,我创建了如下对象:
CloseableHttpClient client = HttpClients.createDefault();
在IDE中运行程序没问题,一切正常。但是,如果我构建并尝试运行 .exe 文件,我会得到以下Throwable
-StackTrace:
java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.conn.ssl.SSLConnectionSocketFactory
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:955)
at org.apache.http.impl.client.HttpClients.createDefault(HttpClients.java:58)
at ch.itcb.tools.lom.util.JsonSimpleUtil.http(JsonSimpleUtil.java:29)...
我真的不明白这一点。怎么可能只有这个类没有找到,而我所有的其他类都找到了?
我的 build.gradle 文件:
apply plugin: 'java'
apply plugin: 'eclipse'
apply from: 'javafx.plugin'
sourceCompatibility = 1.8
version = '0.1'
jar {
manifest {
attributes 'Implementation-Title': 'LogoffManager',
'Implementation-Version': version
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'lib', include: ['*.jar'])
compile 'ch.qos.logback:logback-classic:1.1.3'
compile 'org.apache.httpcomponents:httpclient:4.5.1'
compile 'com.googlecode.json-simple:json-simple:1.1'
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
test {
systemProperties 'property': 'value'
}
uploadArchives {
repositories {
flatDir {
dirs 'repos'
}
}
}
如果您需要更多信息,请写评论。谢谢。