Maven基础学习总结

Maven学习总结

  1. Maven基本命令

       mvn test-compile      编译测试代码
    
       mvn test                    运行应用程序中的单元测试
    
       mvn site                    生成项目相关信息的网站
    
       mvn clean                 清楚项目中的生成结果
    
       mvn package            根据项目生成jar
    
       mvn install                 在本地repo中安装jar
    
       mvn deploy                发布项目
    
       mvn compile              编译源码
    
       mvn archetype           创建源码项目
    
  2. Maven的聚合集成

聚合:

create a simple project (skip archetype selection)
artifactId:项目名-aggregator
packaging:pom
在pom.xml中写

      

                ../子项目名1

                ../子项目名2

      

集成:

      1. 同上1,2,在pom.xml中,在每个子项目的pom.xml中

      

                项目整体的名称 

                父项目名

                父项目名版本

                 ../父项目名/pom.xml

      

      2. 在parent的pom.xml中

      

                 4.3.5.RELEASE

                 …管理版本…

      

      

      

                

                          jar包相关的项目整体的名称

                          jar包名

                          ${project.version}

                

      
  1. 注意的是,每当更换工作空间时,在preference中要设置好settings,同时在settings.xml中加入mirror,指定使用国内的阿里云镜像包,建议使用阿里云的镜像库文件:

        
    
                    nexus
    
                    *
    
                    http://maven.aliyun.com/nexus/content/groups/public/
    
         
    
         
    
                 nexus-public-snapshots
    
                 public-snapshots
    
                    http://maven.aliyun.com/nexus/content/repositories/snapshots/
    
         
    
  2. Maven的依赖特性:最短路径原则、最先申明原则

  3. Maven的常见问题总结:

        1》 maven -- 问题解决(二)解决“Could not calculate build plan”问题
    
        https://www.cnblogs.com/lmei/p/4780453.html
    
        2》 SSH框架整合出现“LifecycleProcessor not initialized - call 'refresh' before invoking”问题
    
        https://blog.csdn.net/alan_liuyue/article/details/53302216 缺少jar包
    
        3》 当mvn中央仓库中没有想要的jar包时,需要手动添加jar
    
        https://blog.csdn.net/qq_30698633/article/details/78328842
    
        示例:
    
        mvn install:install-file -Dfile=lucene-queryparser-4.6.1.jar -DgroupId=org.apache.lucene -DartifactId=lucene-queryparser -           Dversion=4.6.1 -Dpackaging=jar
    
        4》Description Resource Path Location Type Archive for required library: 'D:/repository/ued
    
        https://blog.csdn.net/tengdazhang770960436/article/details/53105509
    
        5》maven编译时出现读取XXX时出错invalid LOC header (bad signature)
    
        https://blog.csdn.net/woshixuye/article/details/14669929
    

原文:https://blog.csdn.net/Juwenzhe_HEBUT/article/details/82024050

你可能感兴趣的:(Maven基础学习总结)