Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.8k views
in Technique[技术] by (71.8m points)

使用 gradle 打包 jar 包时,貌似如果依赖的 jar 包过多,执行 jar 包时就会报找不到或无法加载主类怎么办?

小弟目前想要开发调用 KETTLE 作业的程序,由于需要引用 KETTLE 中所有依赖 jar 包,打包完的 jar 包大小约有 160M 。结果执行时报错“错误: 找不到或无法加载主类”。gradle 结构非常简单,如下:

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.4.21'
    id 'com.github.johnrengelman.shadow' version '6.1.0'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib"
    compile fileTree(dir:'/Users/xxl/data-integration8.2/lib',include:['*.jar'])
}

jar {
    from { configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
    //设置 zip64,避免报 65535 错误
    zip64 true
} 

只要将 compile fileTree(dir:'/Users/xxl/data-integration8.2/lib',include:['*.jar'])注释,或者减少依赖 jar 包数量,执行就可以正常(不过就会因为缺少依赖报 java.lang.NoClassDefFoundError 了 T.T )

请问这种情况如何处理呢,非常感谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...