设为首页 收藏本站
查看: 730|回复: 0

[经验分享] apache-maven-3.0.4

[复制链接]

尚未签到

发表于 2015-8-6 08:58:33 | 显示全部楼层 |阅读模式
  apache-maven-3.0.4
  HOW TO ...
  how to setting locale repository
  configure apache-maven-3.0.4\conf\settings.xml
    
  C:/maven-repository
  copy the "apache-maven-3.0.4\conf\settings.xml" file to new locale repository "C:\maven-repository".
  Then maven will update locale repository from remote Central Repository.
  The lib download from remote Central Repository will store in C:\maven-repository.
  how to change remote Central Repository address
  configure pom.xml in your project like this.
     
        
            central
            Central Repository
            https://nexus.sourcesense.com/nexus/content/repositories/public/
            default
            
            
                true
            
            
            
                true
            
        
   
  Then new Central Repository address "https://nexus.sourcesense.com/nexus/content/repositories/public/" will replace the dafault Central Repository address configure in "apache-maven-3.0.4\lib\maven-model-builder-3.0.4.jar\org\apache\maven\model\pom-4.0.0.xml".
    
   
      central
      Central Repository
      http://repo.maven.apache.org/maven2
      default
      
        false
      
   
  
  http://repo.maven.apache.org/maven2 is the default Central Repository address.
  And another way to change central repository configure in "apache-maven-3.0.4\lib\maven-model-builder-3.0.4.jar\org\apache\maven\model\pom-4.0.0.xml" is to configure your locale repository (C:\maven-repository\settings.xml) like this.
  add profile configure to profiles elements and active it.
     
      central-repos
      
        
          central
          Central Repository
          https://nexus.sourcesense.com/nexus/content/repositories/public/
          default
         
         
            true
         
         
         
            true
         
        
      
   
  
  
  
    central-repos
  
  how to solve dependency conflict
  same dependency path length - first come, first use
  user-core depends on log4j-1.2.16
  user-log depends on log4j-1.29
  user-dao depends on user-core and user-log
  which log4j should user-dao depends on?
  user-core pom.xml
   tos.maven.user
user-core
0.0.1-SNAPSHOT
    
   log4j
   log4j
   1.2.16
  
  user-log pom.xml
   tos.maven.user
user-log
0.0.1-SNAPSHOT
     
   log4j
   log4j
   1.2.9
  
  user-dao pom.xml
  
   tos.maven.user
   user-core
   0.0.1-SNAPSHOT
  
    
   tos.maven.user
   user-log
   0.0.1-SNAPSHOT
  
  in pom.xml of user-dao which dependency come first, the corresponding log4j will be used, so user-dao will use log4j-1.2.16.
  different dependency path length - short come, first use
  user-service depends on user-dao and user-dao depends on user-core (which depends on log4j-1.2.16).
  user-service depends on user-log (which depends on log4j-1.2.9).
  then user-service will use log4j-1.2.9 because the length of dependency path is shorter than another (log4j-1.2.16).
  if you want to controll exactly which log4j should be used, you can add exclusions element like this.
    
   tos.maven.user
   user-log
   0.0.1-SNAPSHOT
   
   
     log4j
     log4j
   
   
  
  then user-service will use log4j-1.2.16.
  if you want to use log4j-1.2.9. you can change pom.xml of use-service like this
    
   tos.maven.user
   user-log
   0.0.1-SNAPSHOT
   
   
     log4j
     log4j
   
   
  
  
   tos.maven.user
   user-dao
   0.0.1-SNAPSHOT
  
  
   log4j
   log4j
   1.2.9
  
  because log4j-1.2.9 is the most short dependency path for now.
  how to aggregation mutil project

  aggregation user-core, user-log, user-dao, user-service together.

    4.0.0
  tos.maven.user
  user-aggregation
  0.0.1-SNAPSHOT
  pom
   
        ../user-core
        ../user-log
        ../user-dao
        ../user-service
   
  how to extends
  user-parent pom.xml
      tos.maven.user
    user-parent
    0.0.1-SNAPSHOT
    pom
    
        
            
                ..
                ..
                ..
            
        
   
  user-component pom.xml

     
        tos.maven.user
        user-parent
        0.0.1-SNAPSHOT
        ../user-parent/pom.xml
   
     
        
            ..
            ..
        
   
  how to use plugins
  source plugin
  jar-no-fork: package java source file
  configure source plugin in user-parent pom.xml
  the following configuration will binding source plugin goal jar-no-fork to phase package
  
  
   
   
     org.apache.maven.plugins
     maven-source-plugin
     2.2
     
      
       package
      
        jar-no-fork
      
      
     
   
   
  

  user-component pom.xml
  
  
   
    org.apache.maven.plugins
    maven-source-plugin
   
  

  help plugin
  describe: display help information of special plugin
  The plugin parameter is meant to provide two things: convenience and prefix-based access.
  The convenience comes when specifying a plugin by groupId:artifactId:version. Where the more traditional specification of separate fields would mean specifying this:
  mvn help:describe -DgroupId=org.apache.maven.plugins -DartifactId=maven-compiler-plugin -Dversion=2.5.1
  the use of the plugin parameter allows this:
  mvn help:describe -Dplugin=org.apache.maven.plugins:maven-compiler-plugin:2.5.1
  On the other hand, the plugin parameter also offers the option to specify a plugin by its prefix, like this:
  mvn help:describe -Dplugin=compiler
  sql plugin
  set properties
  
  com.mysql.jdbc.Driver
  jdbc:mysql://localhost:3306/mysql
  root
  mysqladmin

  configure plugin
     
    org.codehaus.mojo
    sql-maven-plugin
    1.5
   
     
      mysql
      mysql-connector-java
      5.1.21
     
   
   
     ${mysql.driver}
     ${mysql.url}
     ${mysql.username}
     ${mysql.password}
     
      create database if not exists maven_sql_plugin
     
   
   
     
      package
      
       execute
      
     
   
   
  how to deploy your project to tomcat
  setting scope=provided - compile and test will use those jar, but when package your project the jar will not included.
     
    servletapi
    servletapi
    2.4
    provided
   
     
    javax.servlet.jsp
    jsp-api
    2.2
    provided
   
  And use war-plugin and cargo-plugin to deploy to tomcat.
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-94588-1-1.html 上篇帖子: Apache Jackrabbit源码研究(四) 下篇帖子: 在win中配置Apache,PHP及MySQL小记
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表