How to add local .jar file dependency to build.gradle file?

前端 未结 17 2072
攒了一身酷
攒了一身酷 2020-11-21 23:23

So I have tried to add my local .jar file dependency to my build.gradle file:

apply plugin: \'java\'

sourceSets {
    main {
        java {
            srcD         


        
17条回答
  •  北荒
    北荒 (楼主)
    2020-11-21 23:51

    You can add jar doing:

    For gradle just put following code in build.gradle:

    dependencies {
    ...
    compile fileTree(dir: 'lib', includes: ['suitetalk-*0.jar'])
    ...
    }
    

    and for maven just follow steps:

    For Intellij: File->project structure->modules->dependency tab-> click on + sign-> jar and dependency->select jars you want to import-> ok-> apply(if visible)->ok

    Remember that if you got any java.lang.NoClassDefFoundError: Could not initialize class exception at runtime this means that dependencies in jar not installed for that you have to add all dependecies in parent project.

提交回复
热议问题