maven常用打包插件

1.使用maven的时候,有时候会遇到各种打包的情况,下面总结了常用的几个打包插件,一般情况下已经够用了。
        SxInnovate
        
            
                org.apache.maven.plugins
                maven-compiler-plugin
                2.3.2
                
                    1.7
                    1.7
                    UTF-8
                    
                        
                        ${java.home}/lib/rt.jar
                    
                
            
            
                org.apache.maven.plugins
                maven-dependency-plugin
                
                    ${project.build.directory}/lib
                    false 
                    false 
                

                
                    
                        copy-dependencies
                        package
                        
                            copy-dependencies
                        
                        
                            
                            ${project.build.directory}/lib
                            false
                            false
                        
                    
                
            
            
            
                org.apache.maven.plugins
                maven-resources-plugin
                2.6
                
                    
                        copy-resources
                        package
                        
                            copy-resources
                        
                        
                            UTF-8
                            
                            ${project.build.directory}/conf
                            
                                
                                    src/main/resources/
                                    true
                                    
                                        *.bat
                                        *.sh
                                    
                                
                            
                        
                    
                    
                        copy-command
                        package
                        
                            copy-resources
                        
                        
                            UTF-8
                            
                            ${project.build.directory}/bin
                            
                                
                                    src/main/resources/
                                    true
                                    
                                        *.bat
                                        *.sh
                                    
                                
                            
                        
                    
                
            

            
            
                org.apache.maven.plugins
                maven-jar-plugin
                2.4
                
                    
                        
                        false
                        
                        
                            
                            true
                            lib/
                            
                            com.boco.Application
                        
                        
                            
                            conf/
                        
                    
                    ${project.build.directory}/
                    
                        
                        **/*.class
                    
                
            
            
                org.apache.maven.plugins
                maven-assembly-plugin
                2.4
                
                
                    
                    
                        package.xml
                    
                   
                
                
                    
                        make-assembly
                        package
                        
                            single
                        
                    
                
            
        
    
上面的package.xml文件内容如下:
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
    distribution
    
        zip
    

    
        
            ${project.basedir}\src\main\resources
            \conf
          

            
        

        
            ${project.basedir}\src\bin
            \bin
        

        
            ${project.basedir}\lib
            \lib
        
    

    
        
            true
            lib
            
            runtime
        
    

另外,两个小知识点:
1.将本地jar安装到本地仓库,解决像oracle连接驱动引用不了的问题。
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.2.0 -Dpackaging=jar -Dfile=E:\oracle\ojdbc14-10.2.0.2.0.jar
2.项目依赖本地路径jar包

首先我在项目根目录中创建一个lib文件夹,将jar包拷贝到lib文件夹下

然后我们在maven的pom.xml中配置

<groupId>org.aaa.bbbgroupId>  
<artifactId>kkkartifactId>  
<version>1.0version>  
<scope>systemscope>  
<systemPath>${project.basedir}/lib/aaa.jarsystemPath>  
这里的groupId和artifactId以及version都是可以随便填写的 ,scope必须填写为system,而systemPath我们现在我们jar包的地址就可以了


你可能感兴趣的:(maven)