zoukankan      html  css  js  c++  java
  • 5) mvn archetype:generate

    获取帮助

    mvn -h

    命令格式

    usage: mvn [options] [<goal(s)>] [<phase(s)>]

    -D,--define <arg> Define a system property

    Defines a system property. This will take priority over any other property specified.

    eg. 

    mvn archetype:generate -D archetypeCatalog=file://E:/e/maven

    mvn archetype:generate -DarchetypeCatalog=file://E:/e/maven

    mvn archetype:generate --define archetypeCatalog=file://E:/e/maven

    其中第二种方式较为常用

    ================================================================================

    mvn archetype:generate

    (1) 使用步骤

    点击查看具体参数及用法

    mvn -l E:emavenlog.txt archetype:generate

    步骤:

    1.默认为setting.xml 中的interactiveMode 交互模式

    2.列出原型

    3.选择原型,默认为maven-archetype-quickstart (或者过滤原型后,从结果集中重新选择原型)

    4.选择version

    5.定义groupId

    6.定义artifactId

    7.定义version

    8.定义package

    9.确认

    备注:输入值可以覆盖默认值,不输入则以默认值为准。

    (2) Optional Parameters

    archetypeCatalog

    The archetype catalogs to use to build a list and let the user choose from. It is a comma separated list of catalogs. Catalogs use the following schemes:

    • 'file://...' with archetype-catalog.xml automatically appended when pointing to a directory
    • 'http://...' or 'https://...' with archetype-catalog.xml always appended
    • 'local' which is the shortcut for 'file://~/.m2/archetype-catalog.xml'
    • 'remote' which is the shortcut for Maven Central repository, ie 'http://repo.maven.apache.org/maven2'
    • 'internal' which is an internal catalog

    Since 2.0-alpha-5, default value is no longer internal,local but remote,local. If Maven Central repository catalog file is empty, internal catalog is used instead.
    Default value isremote,local.
    User property isarchetypeCatalog.

    说明:

    该参数指定多个时以","英文逗号分割。

    如果指定的是目录则自动拼接archetype-catalog.xml 

    不设置改参数时默认使用remote,local

    当使用remote时会从maven中央仓库获取xml文件,即:http://repo.maven.apache.org/maven2/archetype-catalog.xml

    中央仓库获取文件会很慢,可以用迅雷等工具下载到本地,以'file://...'形式使用

    (3) archetype-catalog.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <archetype-catalog>
      <archetypes>
         <archetype>
          <groupId>org.apache.maven.archetypes</groupId>
          <artifactId>maven-archetype-quickstart</artifactId>
          <version>1.1</version>
          <description>An archetype which contains a sample Maven project.</description>
        </archetype>
      </archetypes>
    </archetype-catalog>

    构建此原型时,如果本地仓库没有,会下载

    Downloading: file://E:/e/maven/org/apache/maven/archetypes/maven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.jar
    Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.jar
    Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.jar (7 KB at 9.5 KB/sec)
    Downloading: file://E:/e/maven/org/apache/maven/archetypes/maven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.pom
    Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.pom
    Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.pom (2 KB at 5.5 KB/sec)

    查看下载的pom.xml 文件

    <scm>
        <connection>scm:svn:http://svn.apache.org/repos/asf/maven/archetype/tags/maven-archetype-quickstart-1.1</connection>
        <developerConnection>..此处省略..</developerConnection>
        <url>http://svn.apache.org/viewvc/maven/archetype/tags/maven-archetype-quickstart-1.1</url>
    </scm>

    Source Control Management
    代码下载地址显而易见

    (4) 完整示例

  • 相关阅读:
    解决VS在查找预编译头使用时跳过
    Very Sleepy使用图文教程
    将Excel数据导入到ArcGIS属性表
    2016工作计划
    免费GIS数据下载网站推荐
    WIN7 (64 位)安装AutoCAD2012失败解决方法
    .resources文件转.resx 文件
    同一Session中的aspx页面的并发限制
    Diving Into Lync Client Logins
    Passing JavaScript Objects to Managed Code
  • 原文地址:https://www.cnblogs.com/zno2/p/4496745.html
Copyright © 2011-2022 走看看