How to add local jar files to a Maven project?

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

    I'd like such solution - use maven-install-plugin in pom file:

    
        org.apache.maven.plugins
        maven-install-plugin
        2.5.2
        
            
                initialize
                
                    install-file
                
                
                    lib/yourJar.jar
                    com.somegroup.id
                    artefact-id
                    x.y.z
                    jar
                
            
        
    
    

    In this case you can perform mvn initialize and jar will be installed in local maven repo. Now this jar is available during any maven step on this machine (do not forget to include this dependency as any other maven dependency in pom with tag). It is also possible to bind jar install not to initialize step, but any other step you like.

提交回复
热议问题