问题
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.


It's strange for me because it works perfectly fine when I run it in IntelliJ IDEA.
回答1:
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)
}
}
}
来源:https://stackoverflow.com/questions/54893741/intellij-grade-build-jar-with-dependencies