一、Maven命令简介
Maven提供了一套命令可以用来创建Java工程、编译、打包等操作。通过这些命令来处理工作变得更方便、简洁。
Maven工程结构和内容被定义在pom.xml文件中,全称project object moduel
当我们创建一个Maven工程时,Maven会创建默认的工程结构,开发者只需要合理的放置配置文件,而在pom.xml文件中无需做任何配置。
二、Maven创建工程命令
mvn clean:表示运行清理操作(会默认把target文件夹中的数据清理)。
mvn clean compile:表示先运行清理之后运行编译,会将代码编译到target文件夹中。
mvn clean test:运行清理和测试。
mvn clean package:运行清理和打包。
mvn clean install:运行清理和安装,会将打好的包安装到本地仓库中,以便其他的项目可以调用。
mvn clean deploy:运行清理和发布(发布到私服上面)。
上面的命令大部分都是连写的,大家也可以拆分分别执行,这是活的,看个人喜好以及使用需求,Eclipse Run as对maven项目会提供常用的命令。
Maven创建工程命令格式:
mvn archetype:generate -Dgroupid #公司名称 -DartifactId #项目名称 -DarchetypeArtifactId #archetypeArtifactId 模型(骨架) -DinteractiveMode #是否使用交互模式
备注:archetypeArtifactId模型(骨架):
(1)指定为maven-archetype-quickstart,创建一个java project工程;
(2)指定为maven-archetype-webapp ,创建一个web project工程。
1、使用maven-archetype-quickstart骨架来创建java project
在D盘下新建maven文件夹,进入d:maven下,按着shift键同时右键,会弹出“在此处打开命令窗口(W)”
在打开的cmd窗口中输入命令:mvn archetype:generate,此时如果你是第一次执行该命令,就会下载很多插件。
当需要下载的内容下载完成之后,就开始填写参数类创建工程(注意:本人配置过阿里云远程仓库,所以下载路径不一样)
。。。。。。。
776: remote -> com.sun.jersey.archetypes:jersey-quickstart-webapp (An archetype which contains a sample Jersey based Webapp project.) Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co ntains): 579: maven-archetype-quickstart #输入骨架名称,可以自动筛选如骨架编号 Choose archetype: 1: remote -> org.apache.maven.archetypes:maven-archetype-quickstart (An archetyp e which contains a sample Maven project.) Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co ntains): 1: 1 #输入骨架对应的编号 Choose org.apache.maven.archetypes:maven-archetype-quickstart version: 1: 1.1 2: 1.3 Choose a number: 2: 2 #输入应用骨架的版本 Downloading from maven-archetype-quickstart-repo: http://maven.aliyun.com/nexus/ content/groups/public/org/apache/maven/archetypes/maven-archetype-quickstart/1.3 /maven-archetype-quickstart-1.3.pom Downloaded from maven-archetype-quickstart-repo: http://maven.aliyun.com/nexus/c ontent/groups/public/org/apache/maven/archetypes/maven-archetype-quickstart/1.3/ maven-archetype-quickstart-1.3.pom (1.6 kB at 636 B/s) Downloading from maven-archetype-quickstart-repo: http://maven.aliyun.com/nexus/ content/groups/public/org/apache/maven/archetypes/maven-archetype-bundles/1.3/ma ven-archetype-bundles-1.3.pom Downloaded from maven-archetype-quickstart-repo: http://maven.aliyun.com/nexus/c ontent/groups/public/org/apache/maven/archetypes/maven-archetype-bundles/1.3/mav en-archetype-bundles-1.3.pom (4.5 kB at 1.6 kB/s) Downloading from maven-archetype-quickstart-repo: http://maven.aliyun.com/nexus/ content/groups/public/org/apache/maven/maven-parent/31/maven-parent-31.pom Downloaded from maven-archetype-quickstart-repo: http://maven.aliyun.com/nexus/c ontent/groups/public/org/apache/maven/maven-parent/31/maven-parent-31.pom (43 kB at 14 kB/s) Downloading from maven-archetype-quickstart-repo: http://maven.aliyun.com/nexus/ content/groups/public/org/apache/apache/19/apache-19.pom Downloaded from maven-archetype-quickstart-repo: http://maven.aliyun.com/nexus/c ontent/groups/public/org/apache/apache/19/apache-19.pom (15 kB at 4.8 kB/s) Downloading from maven-archetype-quickstart-repo: http://maven.aliyun.com/nexus/ content/groups/public/org/apache/maven/archetypes/maven-archetype-quickstart/1.3 /maven-archetype-quickstart-1.3.jar Downloaded from maven-archetype-quickstart-repo: http://maven.aliyun.com/nexus/c ontent/groups/public/org/apache/maven/archetypes/maven-archetype-quickstart/1.3/ maven-archetype-quickstart-1.3.jar (7.0 kB at 2.3 kB/s) Define value for property 'groupId': com.dx #为公司名称 Define value for property 'artifactId': maven_demo1 #为项目名称 Define value for property 'version' 1.0-SNAPSHOT: : #项目版本,直接回车为默认1.0-SNAPSHOT Define value for property 'package' com.dx: : com.dx.maven_demo1 #包名 Confirm properties configuration: groupId: com.dx artifactId: maven_demo1 version: 1.0-SNAPSHOT package: com.dx.maven_demo1 Y: : y #确认是否为以上参数 [INFO] ------------------------------------------------------------------------- --- [INFO] Using following parameters for creating project from Archetype: maven-arc hetype-quickstart:1.3 [INFO] ------------------------------------------------------------------------- --- [INFO] Parameter: groupId, Value: com.dx [INFO] Parameter: artifactId, Value: maven_demo1 [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] Parameter: package, Value: com.dx.maven_demo1 [INFO] Parameter: packageInPathFormat, Value: com/dx/maven_demo1 [INFO] Parameter: package, Value: com.dx.maven_demo1 [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] Parameter: groupId, Value: com.dx [INFO] Parameter: artifactId, Value: maven_demo1 [INFO] Project created from Archetype in dir: D:mavenmaven_demo1 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:08 min [INFO] Finished at: 2018-07-18T14:34:15+08:00 [INFO] Final Memory: 17M/212M [INFO] ------------------------------------------------------------------------ D:maven>
此时,在d:maven就有一个工程maven_demo1
D:maven. D:mavenmaven_demo1. D:mavenmaven_demo1pom.xml D:mavenmaven_demo1src. D:mavenmaven_demo1srcmain. D:mavenmaven_demo1srcmainjava. D:mavenmaven_demo1srcmainjavacom. D:mavenmaven_demo1srcmainjavacomdx. D:mavenmaven_demo1srcmainjavacomdxmaven_demo1. D:mavenmaven_demo1srcmainjavacomdxmaven_demo1App.java D:mavenmaven_demo1src est. D:mavenmaven_demo1src estjava. D:mavenmaven_demo1src estjavacom. D:mavenmaven_demo1src estjavacomdx. D:mavenmaven_demo1src estjavacomdxmaven_demo1. D:mavenmaven_demo1src estjavacomdxmaven_demo1AppTest.java
备注:bat来遍历d:maven目录
@echo off set work_path=D:maven D: cd %work_path% for /R %%s in (.,*) do ( echo %%s ) pause
2、使用maven-archetype-webapp骨架来创建web
776: remote -> com.sun.jersey.archetypes:jersey-quickstart-webapp (An archetype which contains a sample Jersey based Webapp project.) Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co ntains): 579: maven-archetype-webapp Choose archetype: 1: remote -> org.apache.maven.archetypes:maven-archetype-webapp (An archetype wh ich contains a sample Maven Webapp project.) Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co ntains): : 1 Choose org.apache.maven.archetypes:maven-archetype-webapp version: 1: 1.0 2: 1.3 Choose a number: 2: 2 Downloading from maven-archetype-webapp-repo: http://maven.aliyun.com/nexus/cont ent/groups/public/org/apache/maven/archetypes/maven-archetype-webapp/1.3/maven-a rchetype-webapp-1.3.pom Downloaded from maven-archetype-webapp-repo: http://maven.aliyun.com/nexus/conte nt/groups/public/org/apache/maven/archetypes/maven-archetype-webapp/1.3/maven-ar chetype-webapp-1.3.pom (1.4 kB at 402 B/s) Downloading from maven-archetype-webapp-repo: http://maven.aliyun.com/nexus/cont ent/groups/public/org/apache/maven/archetypes/maven-archetype-bundles/1.3/maven- archetype-bundles-1.3.pom Downloaded from maven-archetype-webapp-repo: http://maven.aliyun.com/nexus/conte nt/groups/public/org/apache/maven/archetypes/maven-archetype-bundles/1.3/maven-a rchetype-bundles-1.3.pom (0 B at 0 B/s) Downloading from maven-archetype-webapp-repo: http://maven.aliyun.com/nexus/cont ent/groups/public/org/apache/maven/maven-parent/31/maven-parent-31.pom Downloaded from maven-archetype-webapp-repo: http://maven.aliyun.com/nexus/conte nt/groups/public/org/apache/maven/maven-parent/31/maven-parent-31.pom (0 B at 0 B/s) Downloading from maven-archetype-webapp-repo: http://maven.aliyun.com/nexus/cont ent/groups/public/org/apache/apache/19/apache-19.pom Downloaded from maven-archetype-webapp-repo: http://maven.aliyun.com/nexus/conte nt/groups/public/org/apache/apache/19/apache-19.pom (0 B at 0 B/s) Downloading from maven-archetype-webapp-repo: http://maven.aliyun.com/nexus/cont ent/groups/public/org/apache/maven/archetypes/maven-archetype-webapp/1.3/maven-a rchetype-webapp-1.3.jar Downloaded from maven-archetype-webapp-repo: http://maven.aliyun.com/nexus/conte nt/groups/public/org/apache/maven/archetypes/maven-archetype-webapp/1.3/maven-ar chetype-webapp-1.3.jar (6.8 kB at 2.2 kB/s) Define value for property 'groupId': com.dx Define value for property 'artifactId': maven_webdemo1 Define value for property 'version' 1.0-SNAPSHOT: : Define value for property 'package' com.dx: : com.dx.maven_webdemo1 Confirm properties configuration: groupId: com.dx artifactId: maven_webdemo1 version: 1.0-SNAPSHOT package: com.dx.maven_webdemo1 Y: : y [INFO] ------------------------------------------------------------------------- --- [INFO] Using following parameters for creating project from Archetype: maven-arc hetype-webapp:1.3 [INFO] ------------------------------------------------------------------------- --- [INFO] Parameter: groupId, Value: com.dx [INFO] Parameter: artifactId, Value: maven_webdemo1 [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] Parameter: package, Value: com.dx.maven_webdemo1 [INFO] Parameter: packageInPathFormat, Value: com/dx/maven_webdemo1 [INFO] Parameter: package, Value: com.dx.maven_webdemo1 [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] Parameter: groupId, Value: com.dx [INFO] Parameter: artifactId, Value: maven_webdemo1 [INFO] Project created from Archetype in dir: D:mavenmaven_webdemo1 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:31 min [INFO] Finished at: 2018-07-18T14:49:39+08:00 [INFO] Final Memory: 17M/215M [INFO] ------------------------------------------------------------------------ D:maven>
查看目录结构
D:mavenmaven_webdemo1. D:mavenmaven_webdemo1pom.xml D:mavenmaven_webdemo1src. D:mavenmaven_webdemo1srcmain. D:mavenmaven_webdemo1srcmain esources. D:mavenmaven_webdemo1srcmainwebapp. D:mavenmaven_webdemo1srcmainwebappindex.jsp D:mavenmaven_webdemo1srcmainwebappWEB-INF. D:mavenmaven_webdemo1srcmainwebappWEB-INFweb.xml
3、maven compile
D:maven>cd D:mavenmaven_demo1 D:mavenmaven_demo1>mvn compile [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building maven_demo1 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/apache/maven/plugins/maven-resources-plugin/3.0.2/maven-resources-plugin-3.0. 2.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/apache/maven/plugins/maven-resources-plugin/3.0.2/maven-resources-plugin-3.0.2 .pom (7.1 kB at 1.6 kB/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/apache/maven/plugins/maven-resources-plugin/3.0.2/maven-resources-plugin-3.0. 2.jar Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/apache/maven/plugins/maven-resources-plugin/3.0.2/maven-resources-plugin-3.0.2 .jar (32 kB at 7.7 kB/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/apache/maven/plugins/maven-compiler-plugin/3.7.0/maven-compiler-plugin-3.7.0. pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/apache/maven/plugins/maven-compiler-plugin/3.7.0/maven-compiler-plugin-3.7.0.p om (11 kB at 2.9 kB/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/apache/maven/plugins/maven-compiler-plugin/3.7.0/maven-compiler-plugin-3.7.0. jar Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/apache/maven/plugins/maven-compiler-plugin/3.7.0/maven-compiler-plugin-3.7.0.j ar (58 kB at 15 kB/s) [INFO] [INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ maven_de mo1 --- Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-utils/3.0.24/plexus-utils-3.0.24.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-utils/3.0.24/plexus-utils-3.0.24.pom (4.1 kB at 1.1 kB/ s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/apache/maven/shared/maven-filtering/3.1.1/maven-filtering-3.1.1.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/apache/maven/shared/maven-filtering/3.1.1/maven-filtering-3.1.1.pom (5.7 kB at 1.3 kB/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-interpolation/1.22/plexus-interpolation-1.22.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-interpolation/1.22/plexus-interpolation-1.22.pom (1.5 k B at 358 B/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.pom (0 B at 0 B/ s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/sonatype/spice/spice-parent/15/spice-parent-15.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/sonatype/spice/spice-parent/15/spice-parent-15.pom (0 B at 0 B/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-interpolation/1.24/plexus-interpolation-1.24.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-interpolation/1.24/plexus-interpolation-1.24.pom (2.6 k B at 536 B/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-utils/3.0.24/plexus-utils-3.0.24.jar Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-interpolation/1.24/plexus-interpolation-1.24.jar Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/apache/maven/shared/maven-filtering/3.1.1/maven-filtering-3.1.1.jar Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar (0 B at 0 B/ s) Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/apache/maven/shared/maven-filtering/3.1.1/maven-filtering-3.1.1.jar (51 kB at 11 kB/s) Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-interpolation/1.24/plexus-interpolation-1.24.jar (79 kB at 17 kB/s) Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-utils/3.0.24/plexus-utils-3.0.24.jar (247 kB at 52 kB/s ) [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory D:mavenmaven_demo1srcmain esourc es [INFO] [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ maven_demo1 - -- Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-java/0.9.2/plexus-java-0.9.2.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-java/0.9.2/plexus-java-0.9.2.pom (2.4 kB at 576 B/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-languages/0.9.2/plexus-languages-0.9.2.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-languages/0.9.2/plexus-languages-0.9.2.pom (2.3 kB at 5 32 B/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/ow2/asm/asm/6.0_BETA/asm-6.0_BETA.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/ow2/asm/asm/6.0_BETA/asm-6.0_BETA.pom (1.9 kB at 499 B/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/ow2/asm/asm-parent/6.0_BETA/asm-parent-6.0_BETA.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/ow2/asm/asm-parent/6.0_BETA/asm-parent-6.0_BETA.pom (5.5 kB at 1.4 kB/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/c om/thoughtworks/qdox/qdox/2.0-M7/qdox-2.0-M7.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/co m/thoughtworks/qdox/qdox/2.0-M7/qdox-2.0-M7.pom (16 kB at 3.6 kB/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-compiler-api/2.8.2/plexus-compiler-api-2.8.2.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-compiler-api/2.8.2/plexus-compiler-api-2.8.2.pom (867 B at 226 B/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-compiler/2.8.2/plexus-compiler-2.8.2.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-compiler/2.8.2/plexus-compiler-2.8.2.pom (4.9 kB at 493 B/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-compiler-manager/2.8.2/plexus-compiler-manager-2.8.2.p om Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-compiler-manager/2.8.2/plexus-compiler-manager-2.8.2.po m (692 B at 182 B/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-compiler-javac/2.8.2/plexus-compiler-javac-2.8.2.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-compiler-javac/2.8.2/plexus-compiler-javac-2.8.2.pom (7 71 B at 204 B/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-compilers/2.8.2/plexus-compilers-2.8.2.pom Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-compilers/2.8.2/plexus-compilers-2.8.2.pom (1.3 kB at 3 61 B/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-java/0.9.2/plexus-java-0.9.2.jar Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/c om/thoughtworks/qdox/qdox/2.0-M7/qdox-2.0-M7.jar Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/ow2/asm/asm/6.0_BETA/asm-6.0_BETA.jar Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-compiler-api/2.8.2/plexus-compiler-api-2.8.2.jar Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-compiler-manager/2.8.2/plexus-compiler-manager-2.8.2.j ar Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-compiler-manager/2.8.2/plexus-compiler-manager-2.8.2.ja r (4.7 kB at 1.3 kB/s) Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o rg/codehaus/plexus/plexus-compiler-javac/2.8.2/plexus-compiler-javac-2.8.2.jar Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-java/0.9.2/plexus-java-0.9.2.jar (31 kB at 8.7 kB/s) Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-compiler-api/2.8.2/plexus-compiler-api-2.8.2.jar (26 kB at 7.3 kB/s) Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/ow2/asm/asm/6.0_BETA/asm-6.0_BETA.jar (56 kB at 15 kB/s) Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/co m/thoughtworks/qdox/qdox/2.0-M7/qdox-2.0-M7.jar (315 kB at 82 kB/s) Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or g/codehaus/plexus/plexus-compiler-javac/2.8.2/plexus-compiler-javac-2.8.2.jar (2 0 kB at 2.9 kB/s) [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to D:mavenmaven_demo1 argetclasses [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:38 min [INFO] Finished at: 2018-07-18T14:53:29+08:00 [INFO] Final Memory: 15M/87M [INFO] ------------------------------------------------------------------------ D:mavenmaven_demo1>
查看目录结构:
D:mavenmaven_demo1src estjavacomdx. D:mavenmaven_demo1src estjavacomdxmaven_demo1. D:mavenmaven_demo1src estjavacomdxmaven_demo1AppTest.java D:mavenmaven_demo1 arget. D:mavenmaven_demo1 argetclasses. D:mavenmaven_demo1 argetclassescom. D:mavenmaven_demo1 argetclassescomdx. D:mavenmaven_demo1 argetclassescomdxmaven_demo1. D:mavenmaven_demo1 argetclassescomdxmaven_demo1App.class D:mavenmaven_demo1 argetmaven-status. D:mavenmaven_demo1 argetmaven-statusmaven-compiler-plugin. D:mavenmaven_demo1 argetmaven-statusmaven-compiler-plugincompile. D:mavenmaven_demo1 argetmaven-statusmaven-compiler-plugincompiledefault-c ompile. D:mavenmaven_demo1 argetmaven-statusmaven-compiler-plugincompiledefault-c ompilecreatedFiles.lst D:mavenmaven_demo1 argetmaven-statusmaven-compiler-plugincompiledefault-c ompileinputFiles.lst
4、maven clean
D:mavenmaven_demo1>mvn clean
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven_demo1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/plugins/maven-clean-plugin/3.0.0/maven-clean-plugin-3.0.0.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/plugins/maven-clean-plugin/3.0.0/maven-clean-plugin-3.0.0.pom (4.
8 kB at 977 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/plugins/maven-clean-plugin/3.0.0/maven-clean-plugin-3.0.0.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/plugins/maven-clean-plugin/3.0.0/maven-clean-plugin-3.0.0.jar (31
kB at 7.1 kB/s)
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ maven_demo1 ---
[INFO] Deleting D:mavenmaven_demo1 arget
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.225 s
[INFO] Finished at: 2018-07-18T15:16:22+08:00
[INFO] Final Memory: 10M/155M
[INFO] ------------------------------------------------------------------------
D:mavenmaven_demo1>
查看目录结构:
D:mavenmaven_demo1. D:mavenmaven_demo1pom.xml D:mavenmaven_demo1src. D:mavenmaven_demo1srcmain. D:mavenmaven_demo1srcmainjava. D:mavenmaven_demo1srcmainjavacom. D:mavenmaven_demo1srcmainjavacomdx. D:mavenmaven_demo1srcmainjavacomdxmaven_demo1. D:mavenmaven_demo1srcmainjavacomdxmaven_demo1App.java D:mavenmaven_demo1src est. D:mavenmaven_demo1src estjava. D:mavenmaven_demo1src estjavacom. D:mavenmaven_demo1src estjavacomdx. D:mavenmaven_demo1src estjavacomdxmaven_demo1. D:mavenmaven_demo1src estjavacomdxmaven_demo1AppTest.java
5、mvn site生成站点目录
D:mavenmaven_demo1>mvn site
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven_demo1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-site-plugin:3.3:site (default-site) @ maven_demo1 ---
[WARNING] Report plugin org.apache.maven.plugins:maven-project-info-reports-plug
in has an empty version.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten t
he stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support buildin
g such malformed projects.
[INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-rep
orts-plugin:2.9
[INFO] Relativizing decoration links with respect to project URL: http://maven.a
pache.org
[INFO] Rendering site with org.apache.maven.skins:maven-default-skin:jar:1.0 ski
n.
[INFO] Generating "Dependencies" report --- maven-project-info-reports-plugin
:2.9
[INFO] Generating "Dependency Convergence" report --- maven-project-info-repo
rts-plugin:2.9
[INFO] Generating "Dependency Information" report --- maven-project-info-repo
rts-plugin:2.9
[INFO] Generating "About" report --- maven-project-info-reports-plugin:2.9
[INFO] Generating "Plugin Management" report --- maven-project-info-reports-p
lugin:2.9
[INFO] Generating "Plugins" report --- maven-project-info-reports-plugin:2.9
[INFO] Generating "Summary" report --- maven-project-info-reports-plugin:2.9
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.808 s
[INFO] Finished at: 2017-06-24T04:48:46+08:00
[INFO] Final Memory: 21M/276M
[INFO] ------------------------------------------------------------------------
查看目录结构:
D:mavenmaven_demo1. D:mavenmaven_demo1pom.xml D:mavenmaven_demo1src. D:mavenmaven_demo1srcmain. D:mavenmaven_demo1srcmainjava. D:mavenmaven_demo1srcmainjavacom. D:mavenmaven_demo1srcmainjavacomdx. D:mavenmaven_demo1srcmainjavacomdxmaven_demo1. D:mavenmaven_demo1srcmainjavacomdxmaven_demo1App.java D:mavenmaven_demo1src est. D:mavenmaven_demo1src estjava. D:mavenmaven_demo1src estjavacom. D:mavenmaven_demo1src estjavacomdx. D:mavenmaven_demo1src estjavacomdxmaven_demo1. D:mavenmaven_demo1src estjavacomdxmaven_demo1AppTest.java D:mavenmaven_demo1 arget. D:mavenmaven_demo1 argetsite. D:mavenmaven_demo1 argetsitedependencies.html D:mavenmaven_demo1 argetsitedependency-convergence.html D:mavenmaven_demo1 argetsitedependency-info.html D:mavenmaven_demo1 argetsiteindex.html D:mavenmaven_demo1 argetsiteplugin-management.html D:mavenmaven_demo1 argetsiteplugins.html D:mavenmaven_demo1 argetsiteproject-info.html D:mavenmaven_demo1 argetsiteproject-summary.html D:mavenmaven_demo1 argetsitecss. D:mavenmaven_demo1 argetsitecssmaven-base.css D:mavenmaven_demo1 argetsitecssmaven-theme.css D:mavenmaven_demo1 argetsitecssprint.css D:mavenmaven_demo1 argetsitecsssite.css D:mavenmaven_demo1 argetsiteimages. D:mavenmaven_demo1 argetsiteimagesclose.gif D:mavenmaven_demo1 argetsiteimagescollapsed.gif D:mavenmaven_demo1 argetsiteimagesexpanded.gif D:mavenmaven_demo1 argetsiteimagesexternal.png D:mavenmaven_demo1 argetsiteimagesicon_error_sml.gif D:mavenmaven_demo1 argetsiteimagesicon_info_sml.gif D:mavenmaven_demo1 argetsiteimagesicon_success_sml.gif D:mavenmaven_demo1 argetsiteimagesicon_warning_sml.gif D:mavenmaven_demo1 argetsiteimages ewwindow.png D:mavenmaven_demo1 argetsiteimageslogos. D:mavenmaven_demo1 argetsiteimageslogosuild-by-maven-black.png D:mavenmaven_demo1 argetsiteimageslogosuild-by-maven-white.png D:mavenmaven_demo1 argetsiteimageslogosmaven-feather.png
其中可以访问D:mavenmaven_demo1 argetsiteindex.html,页面结果为:
6、mvn install(把当前工程生成war或者jar包到本地仓库中)
D:mavenmaven_demo1>mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven_demo1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/plugins/maven-surefire-plugin/2.20.1/maven-surefire-plugin-2.20.
1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/plugins/maven-surefire-plugin/2.20.1/maven-surefire-plugin-2.20.1
.pom (5.2 kB at 1.0 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/surefire/surefire/2.20.1/surefire-2.20.1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/surefire/surefire/2.20.1/surefire-2.20.1.pom (25 kB at 5.2 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/plugins/maven-surefire-plugin/2.20.1/maven-surefire-plugin-2.20.
1.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/plugins/maven-surefire-plugin/2.20.1/maven-surefire-plugin-2.20.1
.jar (40 kB at 8.3 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/plugins/maven-jar-plugin/3.0.2/maven-jar-plugin-3.0.2.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/plugins/maven-jar-plugin/3.0.2/maven-jar-plugin-3.0.2.pom (6.2 kB
at 1.3 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/plugins/maven-jar-plugin/3.0.2/maven-jar-plugin-3.0.2.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/plugins/maven-jar-plugin/3.0.2/maven-jar-plugin-3.0.2.jar (27 kB
at 6.3 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/plugins/maven-install-plugin/2.5.2/maven-install-plugin-2.5.2.po
m
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/plugins/maven-install-plugin/2.5.2/maven-install-plugin-2.5.2.pom
(0 B at 0 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/plugins/maven-install-plugin/2.5.2/maven-install-plugin-2.5.2.ja
r
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/plugins/maven-install-plugin/2.5.2/maven-install-plugin-2.5.2.jar
(0 B at 0 B/s)
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ maven_de
mo1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:mavenmaven_demo1srcmain
esourc
es
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ maven_demo1 -
--
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:mavenmaven_demo1 argetclasses
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @
maven_demo1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:mavenmaven_demo1src est
esourc
es
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ maven
_demo1 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:mavenmaven_demo1 arget est-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ maven_demo1 ---
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/surefire/maven-surefire-common/2.20.1/maven-surefire-common-2.20
.1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/surefire/maven-surefire-common/2.20.1/maven-surefire-common-2.20.
1.pom (9.3 kB at 2.1 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/plugin-tools/maven-plugin-annotations/3.3/maven-plugin-annotatio
ns-3.3.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/plugin-tools/maven-plugin-annotations/3.3/maven-plugin-annotation
s-3.3.pom (0 B at 0 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/plugin-tools/maven-plugin-tools/3.3/maven-plugin-tools-3.3.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/plugin-tools/maven-plugin-tools/3.3/maven-plugin-tools-3.3.pom (0
B at 0 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/surefire/surefire-api/2.20.1/surefire-api-2.20.1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/surefire/surefire-api/2.20.1/surefire-api-2.20.1.pom (3.7 kB at 7
26 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/surefire/surefire-logger-api/2.20.1/surefire-logger-api-2.20.1.p
om
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/surefire/surefire-logger-api/2.20.1/surefire-logger-api-2.20.1.po
m (2.0 kB at 389 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/surefire/surefire-booter/2.20.1/surefire-booter-2.20.1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/surefire/surefire-booter/2.20.1/surefire-booter-2.20.1.pom (8.5 k
B at 1.8 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/plugin-tools/maven-plugin-annotations/3.3/maven-plugin-annotatio
ns-3.3.jar
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/surefire/surefire-booter/2.20.1/surefire-booter-2.20.1.jar
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/surefire/surefire-logger-api/2.20.1/surefire-logger-api-2.20.1.j
ar
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/surefire/maven-surefire-common/2.20.1/maven-surefire-common-2.20
.1.jar
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/surefire/surefire-api/2.20.1/surefire-api-2.20.1.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/plugin-tools/maven-plugin-annotations/3.3/maven-plugin-annotation
s-3.3.jar (0 B at 0 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/codehaus/plexus/plexus-utils/1.5.15/plexus-utils-1.5.15.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/codehaus/plexus/plexus-utils/1.5.15/plexus-utils-1.5.15.jar (0 B at 0 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/surefire/surefire-logger-api/2.20.1/surefire-logger-api-2.20.1.ja
r (13 kB at 2.8 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/slf4j/slf4j-jdk14/1.5.6/slf4j-jdk14-1.5.6.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/surefire/surefire-api/2.20.1/surefire-api-2.20.1.jar (183 kB at 3
8 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/surefire/surefire-booter/2.20.1/surefire-booter-2.20.1.jar (268 k
B at 55 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/slf4j/jcl-over-slf4j/1.5.6/jcl-over-slf4j-1.5.6.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/surefire/maven-surefire-common/2.20.1/maven-surefire-common-2.20.
1.jar (509 kB at 101 kB/s)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar (0 B a
t 0 B/s)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/slf4j/slf4j-jdk14/1.5.6/slf4j-jdk14-1.5.6.jar (0 B at 0 B/s)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6.jar (0 B at 0 B/s)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/slf4j/jcl-over-slf4j/1.5.6/jcl-over-slf4j-1.5.6.jar (0 B at 0 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/surefire/surefire-junit4/2.20.1/surefire-junit4-2.20.1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/surefire/surefire-junit4/2.20.1/surefire-junit4-2.20.1.pom (3.3 k
B at 754 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/surefire/surefire-providers/2.20.1/surefire-providers-2.20.1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/surefire/surefire-providers/2.20.1/surefire-providers-2.20.1.pom
(2.6 kB at 603 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/surefire/surefire-junit4/2.20.1/surefire-junit4-2.20.1.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/surefire/surefire-junit4/2.20.1/surefire-junit4-2.20.1.jar (82 kB
at 17 kB/s)
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.dx.maven_demo1.AppTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.107 s -
in com.dx.maven_demo1.AppTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ maven_demo1 ---
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/maven-archiver/3.1.1/maven-archiver-3.1.1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/maven-archiver/3.1.1/maven-archiver-3.1.1.pom (4.3 kB at 1.0 kB/s
)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/shared/maven-shared-utils/3.0.1/maven-shared-utils-3.0.1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/shared/maven-shared-utils/3.0.1/maven-shared-utils-3.0.1.pom (4.6
kB at 1.0 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/codehaus/plexus/plexus-archiver/3.3/plexus-archiver-3.3.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/codehaus/plexus/plexus-archiver/3.3/plexus-archiver-3.3.pom (5.3 kB at 1.2 kB/
s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/codehaus/plexus/plexus-io/2.7.1/plexus-io-2.7.1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/codehaus/plexus/plexus-io/2.7.1/plexus-io-2.7.1.pom (4.9 kB at 1.2 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/commons/commons-compress/1.11/commons-compress-1.11.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/commons/commons-compress/1.11/commons-compress-1.11.pom (13 kB at 2.3 k
B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/iq80/snappy/snappy/0.4/snappy-0.4.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/iq80/snappy/snappy/0.4/snappy-0.4.pom (15 kB at 2.6 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/tukaani/xz/1.5/xz-1.5.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/tukaani/xz/1.5/xz-1.5.pom (1.9 kB at 369 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/codehaus/plexus/plexus-archiver/3.4/plexus-archiver-3.4.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/codehaus/plexus/plexus-archiver/3.4/plexus-archiver-3.4.pom (5.3 kB at 1.1 kB/
s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/maven-archiver/3.1.1/maven-archiver-3.1.1.jar
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/shared/maven-shared-utils/3.0.1/maven-shared-utils-3.0.1.jar
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/codehaus/plexus/plexus-archiver/3.4/plexus-archiver-3.4.jar
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/commons/commons-compress/1.11/commons-compress-1.11.jar
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/codehaus/plexus/plexus-io/2.7.1/plexus-io-2.7.1.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/maven-archiver/3.1.1/maven-archiver-3.1.1.jar (24 kB at 4.9 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/iq80/snappy/snappy/0.4/snappy-0.4.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/shared/maven-shared-utils/3.0.1/maven-shared-utils-3.0.1.jar (154
kB at 30 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/tukaani/xz/1.5/xz-1.5.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/codehaus/plexus/plexus-archiver/3.4/plexus-archiver-3.4.jar (187 kB at 35 kB/s
)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/commons/commons-compress/1.11/commons-compress-1.11.jar (426 kB at 77 k
B/s)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/iq80/snappy/snappy/0.4/snappy-0.4.jar (58 kB at 5.9 kB/s)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/tukaani/xz/1.5/xz-1.5.jar (100 kB at 9.7 kB/s)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/codehaus/plexus/plexus-io/2.7.1/plexus-io-2.7.1.jar (86 kB at 6.1 kB/s)
[INFO] Building jar: D:mavenmaven_demo1 argetmaven_demo1-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ maven_demo1 --
-
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.pom (0 B at
0 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/o
rg/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/or
g/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar (0 B at
0 B/s)
[INFO] Installing D:mavenmaven_demo1 argetmaven_demo1-1.0-SNAPSHOT.jar to D:
javamaven
epositorycomdxmaven_demo11.0-SNAPSHOTmaven_demo1-1.0-SNAPSHOT.
jar
[INFO] Installing D:mavenmaven_demo1pom.xml to D:javamaven
epositorycomd
xmaven_demo11.0-SNAPSHOTmaven_demo1-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:13 min
[INFO] Finished at: 2018-07-18T15:40:00+08:00
[INFO] Final Memory: 20M/184M
[INFO] ------------------------------------------------------------------------
D:mavenmaven_demo1>
如果没有修改本地仓库地址的话,生成的jar包默认位置为:C:UsersAdministrator.m2 epositorycomdxmaven_demo11.0-SNAPSHOT,但是由于我修改了本地仓库的地址,所以生成的jar包位于:D:javamaven epositorycomdxmaven_demo11.0-SNAPSHOT。
7、mvn package(打包)
D:mavenmaven_demo1>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven_demo1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ maven_d
mo1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:mavenmaven_demo1srcmain
esour
es
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ maven_demo1
--
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @
maven_demo1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:mavenmaven_demo1src est
esour
es
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ mave
_demo1 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ maven_demo1 ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.dx.maven_demo1.AppTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.043 s
in com.dx.maven_demo1.AppTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ maven_demo1 ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.545 s
[INFO] Finished at: 2018-07-18T15:59:20+08:00
[INFO] Final Memory: 12M/126M
[INFO] ------------------------------------------------------------------------
D:mavenmaven_demo1>
打包文件位置:D:mavenmaven_demo1 argetmaven_demo1-1.0-SNAPSHOT.jar
在web工程中,会生成*.war包。
8、mvn clean package(先清理再打包)
D:mavenmaven_demo1>mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven_demo1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ maven_demo1 ---
[INFO] Deleting D:mavenmaven_demo1 arget
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ maven_de
mo1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:mavenmaven_demo1srcmain
esourc
es
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ maven_demo1 -
--
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:mavenmaven_demo1 argetclasses
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @
maven_demo1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:mavenmaven_demo1src est
esourc
es
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ maven
_demo1 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:mavenmaven_demo1 arget est-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ maven_demo1 ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.dx.maven_demo1.AppTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.062 s -
in com.dx.maven_demo1.AppTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ maven_demo1 ---
[INFO] Building jar: D:mavenmaven_demo1 argetmaven_demo1-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.878 s
[INFO] Finished at: 2018-07-18T16:00:47+08:00
[INFO] Final Memory: 18M/177M
[INFO] ------------------------------------------------------------------------
D:mavenmaven_demo1>
9、mvn jar:jar(打包为jar)
D:mavenmaven_demo1>mvn jar:jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven_demo1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-cli) @ maven_demo1 ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.780 s
[INFO] Finished at: 2018-07-18T16:02:18+08:00
[INFO] Final Memory: 10M/155M
[INFO] ------------------------------------------------------------------------
D:mavenmaven_demo1>
声明:博文参考作者:cctext 链接:http://www.cnblogs.com/yy3b2007com/p/7045999.html