zoukankan      html  css  js  c++  java
  • maven

    maven命令分为 build phase(build lifecycle phase) 和 plugin goal 两种。

    例如命令:mvn clean dependency:copy-dependencies package,clean 和 package 是 build phase,而 dependency:copy-dependencies 是 plugin goal。

    Maven 命令手册:http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

    执行 plugin goal 有如下几种方式:(https://cwiki.apache.org//confluence/display/MAVEN/LifecyclePhaseNotFoundException
    1. 通过 plugin 前缀(plugin prefix)
    例如:mvn compiler:compile
    最终,plugin prefix 会被转换成 plugin 的 group id 和 artifact id。Maven 解析 plugin prefixes 时,会去查找当前工程的 pom,然后去找到 pom 中用户指定的 plugin groups 定义。

    2. 通过无版本的 plugin 坐标
    例如:mvn org.apache.maven.plugins:maven-compiler-plugin:compile
    为了解析 plugin 的版本,Maven 将会去当前工程的 pom 中去查找用户定义的最新的 plugin 版本

    3. 通过 plugin 的全坐标
    例如:mvn org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile

    maven命令收集

    mvn tomcat:run                默认使用的是8080端口

    mvn -Dmaven.tomcat.port=8081 tomcat:run    指定端口

    mvn tomcat:run -Denv=prod            指定profile (env是maven profile里面的变量?现在工程用 disconf-env ?)

    mvnDebug tomcat7:run         调试模式启动,然后在eclipse中 Debug Configurations 中添加 Remote Java Application,填写 host 和 port,就可以进行调试了。

    mvn clean package -P local            指定 profile 打包

    mvn jetty:run

    mvn install -Dmaven.test.skip=true         忽略单元测试(或者:-DskipTests=true)

    mvn clean -U                 强制更新依赖,同 eclipse 中的 Maven > Update Project 功能相同

    mvn dependency:sources            Maven 下载源码

    mvn dependency:copy-dependencies      Maven 拷贝依赖 jar

    Maven将jar包 install 到本地库

    mvn install:install-file -Dfile=D:trace-bin-1.3.9uildtrace-agent.jar -DgroupId=com.sun.tools.btrace -DartifactId=btrace-agent -Dversion=1.3.9 -Dpackaging=jar
    mvn install:install-file -Dfile=D:trace-bin-1.3.9uildtrace-boot.jar -DgroupId=com.sun.tools.btrace -DartifactId=btrace-boot -Dversion=1.3.9 -Dpackaging=jar

    本地就可以通过下面的 dependency 来依赖这个 jar 了:

    <dependency>
        <groupId>com.sun.tools.btrace</groupId>
        <artifactId>btrace-agent</artifactId>
        <version>1.3.9</version>
    </dependency>
    <dependency>
        <groupId>com.sun.tools.btrace</groupId>
        <artifactId>btrace-boot</artifactId>
        <version>1.3.9</version>
    </dependency>
    View Code

    资料:

    maven配置:http://www.cnblogs.com/yakov/archive/2011/11/26/maven2_settings.html
    官网资料:http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
    问题资料:https://cwiki.apache.org//confluence/display/MAVEN/LifecyclePhaseNotFoundException

  • 相关阅读:
    js正则表达式中的问号使用技巧总结
    380. Insert Delete GetRandom O(1)
    34. Find First and Last Position of Element in Sorted Array
    162. Find Peak Element
    220. Contains Duplicate III
    269. Alien Dictionary
    18. 4Sum
    15. 3Sum
    224. Basic Calculator
    227. Basic Calculator II
  • 原文地址:https://www.cnblogs.com/kevin-yuan/p/7477634.html
Copyright © 2011-2022 走看看