获取帮助

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:\e\maven\log.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) 完整示例

5) mvn archetype:generate的更多相关文章

  1. 使用mvn archetype:generate生产maven工程,响应很慢

    经常到下列时就不往下走了. 解决方案: 1.不使用interactive mode方式,直接指定DarchetypeArtifactId 2.仍使用interactive mode方式,但增加参数 - ...

  2. mvn archetype:create和mvn archetype:generate

    create is deprecated in maven 3.0.5 and beyond,在maven3.0.5以上版本舍弃了create,使用generate生成项目 before:mvn ar ...

  3. idea新建maven项目时,mvn archetype:generate 速度缓慢

    原文 idea新建maven项目时,mvn archetype:generate 速度缓慢 1 现象: 用IDEA新建maven项目,填写完各种参数,创建时,控制台卡在“[INFO] Generati ...

  4. 通过mvn archetype:generate创建Maven项目模板慢的问题

    通过mvn archetype:generate这种交互方式来创建Maven项目模板的时候,经常会长时间卡在Generating project in Interactive mode这一行提示(图1 ...

  5. mvn archetype:generate 创建Maven项目

    mvn archetype:generate 创建Maven项目 mvn compile 编译源代码 mvn deploy 发布项目 mvn test-compile 编译测试源代码 mvn test ...

  6. 使用mvn archetype:generate快速建立Maven项目目录结构

    1.mvn archetype:generate  按照提示进行选择,默认选的话可以直接按回车键 2.mvn archetype:generate -DgroupId=组织名,公司网址的反写+项目名 ...

  7. Maven实战错误笔记:使用mvn archetype:generate报错:Unable to add module to the current project as it is not of packaging type 'pom'

    在使用mvn archetype:generate生成Maven实战03:HelloWorld中的HelloWorld的项目骨架时报了这个错,从字面上分析是可能与pom.xml文件有关,然后我看了一下 ...

  8. idea maven mvn archetype:generate 速度缓慢问题(转)

    From:https://my.oschina.net/u/225373/blog/468035   maven 骨架生成项目速度慢的令人发指,都在Generating project in Batc ...

  9. maven archetype:generate 命令简化项目模板数量

    在maven里使用 mvn archetype:generate 来创建项目是十分方便的,但有时也不尽然.在网络不好时,从网络上加载 archetype-catalog.xml文件(http://re ...

随机推荐

  1. ios App 文件夹

    转:http://stackoverflow.com/questions/16561779/nssearchpathfordirectoriesindomains-nsuserdomainmask D ...

  2. 深入理解const char*p,char const*p,char *const p,const char **p,char const**p,char *const*p,char**const p

    由于没有const*运算,const实际上修饰的是前面的char*,但不能在定义时转换写成 const(char *)*p,因为在定义是"()"是表示函数. 三.深入理解7种组合 ...

  3. Enum学习中的compareTo方法分析

    今天看工厂模式的时候里面用了枚举定义各种可能的实例类型,就看了一下枚举,发现里面有一个compareTo(E o)方法 通过Object的getClass()方法比较两个两个比校对象类型是否一致,如果 ...

  4. LitJson JavaScriptSerializer

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  5. JPEG和Variant的转换

    unit Unit1; interface uses   Windows, Messages, SysUtils, Classes, Graphics, Controls,       Forms, ...

  6. GO.db

    相似的基因在不同物种中,其功能往往保守的.显然,需要一个统一的术语用于描述这些跨物种的同源基因及其基因产物的功能,否则,不同的实验室对相同的基因的功能的描述不同,将极大限制学术的交流.而 Gene O ...

  7. Winform关于OpenFileDialog的使用方法

    1.OpenFileDialog控件有以下基本属性InitialDirectory 对话框的初始目录Filter 要在对话框中显示的文件筛选器,例如,"文本文件(*.txt)|*.txt|所 ...

  8. mac常用软件

    捕捉图片文字的软件:Picatext.v1.0 模拟网络环境的软件:hardware_io_tools_for_xcode__october_2013 读取PDF的软件:PDF Expert 20 马 ...

  9. 关于block元素和inline元素

    呃...这个会不会太基础了.最近在复习,所以基础知识也不能够忽略. 根据HTML 4.01 规范,其描述如下(http://www.w3.org/TR/html401/struct/global.ht ...

  10. Visual Event查看页面相关绑定事件

    页面相关绑定的事件比较复杂,在不熟悉的情况下很难找到相关逻辑的位置,所以希望借助工具来帮自己理清相关事件的脉络走向. 浏览器 工具 chrome( 58.0.3029.110) Visual Even ...