获取帮助

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

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <archetype-catalog>
  3. <archetypes>
  4. <archetype>
  5. <groupId>org.apache.maven.archetypes</groupId>
  6. <artifactId>maven-archetype-quickstart</artifactId>
  7. <version>1.1</version>
  8. <description>An archetype which contains a sample Maven project.</description>
  9. </archetype>
  10. </archetypes>
  11. </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 文件

  1. <scm>
  2. <connection>scm:svn:http://svn.apache.org/repos/asf/maven/archetype/tags/maven-archetype-quickstart-1.1</connection>
  3. <developerConnection>..此处省略..</developerConnection>
  4. <url>http://svn.apache.org/viewvc/maven/archetype/tags/maven-archetype-quickstart-1.1</url>
  5. </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. RabbitMq install on Centos

    安装服务(root) erlang官方安装说明:https://www.erlang-solutions.com/resources/download.html step 1: 安装erlang的yu ...

  2. Jquery和Ajax

    jQuery 是一个 JavaScript 函数库.JavaScript 是 HTML5 以及所有现代浏览器中的默认脚本语言! jQuery 库包含以下特性: HTML 元素选取 HTML 元素操作 ...

  3. Ansible playbooks

    Playbook是Ansible的配置,部署和编排语言. 他们可以描述您希望远程系统执行的策略,或一般IT流程中的一组步骤. 如果Ansible modules是您workshop的工具,则playb ...

  4. chrome 调试参数大全

    一.鼠标事件监控: monitorEvents(document, ["scroll"]); monitorEvents($('#action-button'), ["m ...

  5. 破解版ps

    http://www.sdifen.com/adobe-photoshop-cc.html

  6. configparser模块 logging模块

    configparser模块 固定格式的配置文件 有一个对应的模块去帮你做这个文件的字符串处理 config = configparser.Configparser() config.read(“ex ...

  7. Spring AOP开发

    --------------------siwuxie095                                 Spring AOP 开发         1.在 Spring 中进行 ...

  8. 二叉树中的最大路径和 · Binary Tree Maximum Path Sum

    [抄题]: 给出一棵二叉树,寻找一条路径使其路径和最大,路径可以在任一节点中开始和结束(路径和为两个节点之间所在路径上的节点权值之和) [思维问题]: 不会写分合法 [一句话思路]: 用两次分治:ro ...

  9. discuz回贴通知插件实现-发送邮件

    通过discuz的sendmail()来发送邮件 //引入发送邮件的函数文件 include libfile('function/mail'); //设置收件人地址,标题,内容发送邮件 sendmai ...

  10. .net core web api swagger 配置笔记

    参考网址: --配置步骤见如下链接https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/web-api-help-pages-using-swa ...