How to put all dependencies in separate folder for runnable jar?

前端 未结 1 1966
不思量自难忘°
不思量自难忘° 2020-12-29 12:14

I\'m using mvn package to create a runnable jar with all dependencies packed inside, which runs fine. But I\'d prefer to have all external dependencies packed i

1条回答
  •  一整个雨季
    2020-12-29 12:30

    Use the maven-dependencies-plugin to specify an output directory for the copy-dependencies execution.

    
        org.apache.maven.plugins
        maven-dependency-plugin
        2.5.1
        
          
            copy-dependencies
            package
            
            copy-dependencies
            
            
            ${project.build.directory}/lib/
            
          
        
    
    

    Update:

    To let the jar know where to find the lib folder, you can specify this as a Class-Path value in the manifest using the maven-jar-plugin

    
        org.apache.maven.plugins
        maven-jar-plugin
        
        
            
            true
            lib/
            foo.bar.MainClass
            
        
        
    
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题