获取帮助

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. Optimizing graphics performance

    看U3D文档,心得:对于3D场景,使用分层次的距离裁剪,小物件分到一个层,稍远时就被裁掉,大物体分到一个层,距离很远时才裁掉,甚至不载.中物体介于二者之间. 文档如下: Good performanc ...

  2. <c:forEach>取得集合数量

    这个问题曾经也困扰了我好久,不过以后都没有用过也都忘记了,不过今天在做项目 的时候又遇到了,花费了很久的时间都没有成功.也试了它的很多属性,例如:varStatus.last.${status.cou ...

  3. 将Delphi的对象方法设为回调函数

    心血来潮,为了实现更好的通用性和封装性,需要把类方法作为回调函数,搜得一篇好文,节选转发.命名似乎应该是MethodToCallback才合适,可惜调试时总是报错,debugging. 原文地址:ht ...

  4. 面向对象三大特性一一继承(inheritance)和组合(Composition)

    记住2句话(常识),像个正常人思考! 1.“  is-a ”关系 用 继承! 学生是人,学生继承人这个类, 2. “has-a ”关系 用 组合!电脑有显卡,那么我们就在计算机类中增加显卡属性来复用显 ...

  5. webdriver简介及浏览器的驱动

     1.webdriver概述:  webdriver(selenium2=selenium1+webdriver)是一种用于web应用程序的自动化测试工具,它提供了一套友好的API,与selenium ...

  6. Java的反射和代理以及注解

    最近接触到java的反射和代理(接触的有点迟了...),还是有必要总结下 1. Java的反射 有的时候我们需要在程序运行的时候获取类.方法等信息用于动态运行,这个时候反射就能够帮我们找到类.方法.成 ...

  7. 利用css和javascript实现简单的计算器

    <!doctype html> <html> <head> <!--声明当前页面的编码集--> <meta http-equiv="Co ...

  8. keras—神经网络CNN—MNIST手写数字识别

    from keras.datasets import mnist from keras.utils import np_utils from plot_image_1 import plot_imag ...

  9. Eclipse 中 program arguments 与 VM arguments 的区别

    1. program arguments 中的值作为 主函数中的参数args[] 传入 2. VM Arguments 是设置的java虚拟机的属性,这些系统属性都以-D开头, VM argument ...

  10. Javascript读写CSS属性

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...