How to add local jar files to a Maven project?

后端 未结 30 3322
悲&欢浪女
悲&欢浪女 2020-11-21 04:58

How do I add local jar files (not yet part of the Maven repository) directly in my project\'s library sources?

30条回答
  •  花落未央
    2020-11-21 05:21

    Not an answer to the original question, however it might be useful for someone

    There is no proper way to add multiple jar libraries from the folder using Maven. If there are only few dependencies, it is probably easier to configure maven-install-plugin as mentioned in the answers above.

    However for my particular case, I had a lib folder with more than 100 proprietary jar files which I had to add somehow. And for me it was much easier for me to convert my Maven project to Gradle.

    plugins {
        id 'org.springframework.boot' version '2.2.2.RELEASE'
        id 'io.spring.dependency-management' version '1.0.8.RELEASE'
        id 'java'
    }
    
    group = 'com.example'
    version = '0.0.1-SNAPSHOT'
    sourceCompatibility = '1.8'
    
    repositories {
        mavenCentral()
        flatDir {
           dirs 'libs' // local libs folder
       }
    }
    
    dependencies {
        implementation 'org.springframework.boot:spring-boot-starter-web'
        testImplementation('org.springframework.boot:spring-boot-starter-test') {
            exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
        }
        
        implementation 'io.grpc:grpc-netty-shaded:1.29.0'
        implementation 'io.grpc:grpc-protobuf:1.29.0'
        implementation 'io.grpc:grpc-stub:1.29.0' // dependecies from maven central
    
        implementation name: 'akka-actor_2.12-2.6.1' // dependecies from lib folder
        implementation name: 'akka-protobuf-v3_2.12-2.6.1'
        implementation name: 'akka-stream_2.12-2.6.1'
    
     }
    

提交回复
热议问题