maven打包带依赖和瘦包

带依赖打包,胖包

pom.xml添加如下配置

    
          
              
                  org.apache.maven.plugins
                  maven-assembly-plugin
                  2.4.1
                  
                      
                          jar-with-dependencies
                      
                      
                      	  
                          
                              server.ImportMain
                          
                      

                  
                  
                      
                          make-assembly
                          package
                          
                              single
                          
                      
                  
              
          
      

如上配置打胖包之后,只需要将jar包上传服务器运行即可

依赖单独放文件夹打包,瘦包

pom.xml添加如下配置

  
		
        spark-thrift-jdbc
        
            
            
                src/main/resources
                ${project.build.directory}/config
            
        

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

            
            
                org.apache.maven.plugins
                maven-resources-plugin
                
                    UTF-8
                
            

            
            
                org.apache.maven.plugins
                maven-jar-plugin
                
                    
                        
                            true
                            lib/
                            sparksql.ThriftServerQueriesTest
                        
                        
                        
                            config/
                        
                    
                
            
        
    

如上配置瘦包打包之后,lib和jar在同一目录。所以运行时也需将lib文件夹和jar一同上传到服务器再运行。

你可能感兴趣的:(java)