具有依赖项的Intellij Grade Build Jar [英] Intellij Grade Build Jar with dependencies
问题描述
我想用Gradle在IntelliJ IDEA中构建一个jar文件。
当我在Intellij中运行代码时,一切正常,
,但是当我运行jar文件时出现错误:
I want to build a jar file in IntelliJ IDEA with Gradle. When I run my code in Intellij everything works fine, but when I run the jar file I get an error:
SQLExecption: No suitable driver found for jdbc:sqlite:/applications/elite-dangerous/database/ED_Database.db
我按下构建按钮来构建罐子。
I build the jar throw pressing the build button.
这对我来说很奇怪,因为当我在IntelliJ IDEA中运行它时,它的工作效果很好。
It's strange for me because it works perfectly fine when I run it in IntelliJ IDEA.
推荐答案
使用实现配置包含的依赖项未包含在Jar中,这使得它们在运行时不可用。所以,我想可能是这种情况。您可以尝试将实现更改为编译依赖关系(已弃用,因此不推荐使用),也可以如下所示将依赖关系包含在jar中
Dependencies included using implementation config are not being included in the Jar which makes them not available in runtime. So, I guess that could be the case. You can try changing implementation to compile dependencies ( which is deprecated, so not recommended ) or You can include your dependencies in the jar as below
jar {
manifest {
attributes 'Main-Class': 'eliteDangerousRestUpdater.Main'
}
from {
compileJava.classpath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
这篇关于具有依赖项的Intellij Grade Build Jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!