Intellij Grade Build Jar with dependencies

百般思念 提交于 2019-12-23 04:53:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!