获取帮助
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 (或者过滤原型后,从结果集中重新选择原型)
5.定义groupId
6.定义artifactId
7.定义version
8.定义package
9.确认
备注:输入值可以覆盖默认值,不输入则以默认值为准。
(2) Optional Parameters
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 is: remote,local.
User property is: archetypeCatalog.
说明:
该参数指定多个时以","英文逗号分割。
如果指定的是目录则自动拼接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: 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
代码下载地址显而易见