获取帮助

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) 完整示例

最新文章

  1. IteratorPattern(迭代子模式)
  2. MySQL数据类型 int(M) 表示什么意思?详解mysql int类型的长度值问题
  3. iOS之tabBar随tableView的滑动而隐藏/显现
  4. JS无刷新分页插件
  5. Adobe Scout 入门
  6. http响应报文和http请求报文 详细信息
  7. File not found images\Thumbs.db.
  8. html5上传文件并监听进度
  9. SDPLR的安装过程(matlab)
  10. MFC中DoDataExchange()的作用
  11. 内容页获取当前栏目的上一级栏目ID
  12. docker学习端口连接docker容器---第四章节
  13. ubuntu彻底卸载软件
  14. HashMap(JDK1.8)
  15. Linux Centos下查看cpu、磁盘、内存使用情况,关闭MySQL日志
  16. 基于lfslivecd-x86-6.3-r2145安装vnc和qemu
  17. Zuul 限流
  18. Android requires compiler compliance level 5.0 or 6.0. Found &#39;1.4&#39; instead.解决方法
  19. springMVC学习二 原始springMVC环境搭建
  20. SpringBoot2+WebSocket之聊天应用实战(优化版本)

热门文章

  1. python远程调试及celery调试
  2. 程序员教程-10章-C++程序设计
  3. Mac和iOS开发资源汇总—更新于2013-10-14
  4. Hibernate 的Ehache学习
  5. 岭回归和lasso回归(转)
  6. Anaconda中python加入环境变量
  7. LeanCloud
  8. 两个onCreate方法?你真的了解onCreate()么?
  9. 使用生活实例理解Asp.net运行时
  10. 使用ASP.NET AJAX 从脚本中调用Web 服务的应用方法