How to add local jar files to a Maven project?

后端 未结 30 3237
悲&欢浪女
悲&欢浪女 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:20

    The really quick and dirty way is to point to a local file:

    
          sample  
           com.sample  
           1.0 
          system
          C:\DEV\myfunnylib\yourJar.jar
    
    

    However this will only live on your machine (obviously), for sharing it usually makes sense to use a proper m2 archive (nexus/artifactory) or if you do not have any of these or don't want to set one up a local maven structured archive and configure a "repository" in your pom: local:

    
        
            my-local-repo
            file://C:/DEV//mymvnrepo
        
    
    

    remote:

    
        
            my-remote-repo
            http://192.168.0.1/whatever/mavenserver/youwant/repo
        
    
    

    for this a relative path is also possible using the basedir variable:

    file:${basedir}
    

提交回复
热议问题