Maven命令简介
Maven提供了一套命令可以用来创建java工程、编译、打包等操作。通过这些命令来处理工作变得更方便、简洁。
Maven工程结构和内容被定义在pom.xml文件中,全称project object moduel
当我们创建一个Maven工程时,Maven会创建默认的工程结构,开发者只需要合理的放置配置文件,而在pom.xml文件中无需做任何配置。
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,此时如果你是第一次执行该命令,就会下载很多插件。
当需要下载的内容下载完成后,就开始填写参数等来创建工程
。。。
1871: remote -> us.fatehi:schemacrawler-archetype-plugin-lint (-) Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co ntains): 990: 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.0-alpha-1 2: 1.0-alpha-2 3: 1.0-alpha-3 4: 1.0-alpha-4 5: 1.0 6: 1.1 Choose a number: 6: 6 #输入应用骨架的版本 Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma ven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.pom Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav en-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.pom (2.0 kB at 3.9 kB /s) Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma ven-archetype-bundles/4/maven-archetype-bundles-4.pom Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav en-archetype-bundles/4/maven-archetype-bundles-4.pom (3.6 kB at 6.9 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/mav en-archetype/2.0-alpha-5/maven-archetype-2.0-alpha-5.pom Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/mave n-archetype/2.0-alpha-5/maven-archetype-2.0-alpha-5.pom (8.7 kB at 17 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/ 16/maven-parent-16.pom Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/1 6/maven-parent-16.pom (23 kB at 41 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/apache/apache/7/apache-7.p om Downloaded: https://repo.maven.apache.org/maven2/org/apache/apache/7/apache-7.po m (14 kB at 29 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma ven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.jar Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav en-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.jar (6.2 kB at 12 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 Old (1.x) Archetype: maven-archetype-quickstart:1.1 [INFO] -------------------------------------------------------------- [INFO] Parameter: basedir, Value: D:maven [INFO] Parameter: package, Value: com.dx.maven_demo1 [INFO] Parameter: groupId, Value: com.dx [INFO] Parameter: artifactId, Value: maven_demo1 [INFO] Parameter: packageName, Value: com.dx.maven_demo1 [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] project created from Old (1.x) Archetype in dir: D:mavenmaven_demo1 [INFO] ------------------------------------------------------------- [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------- [INFO] Total time: 06:30 min [INFO] Finished at: 2017-06-23T18:12:18+08:00 [INFO] Final Memory: 17M/262M [INFO] ------------------------------------------------------------- D:maven>
此时,在d:maven就有一个工程maven_demo1
maven_demo1 java工程的目录结构:
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 project
1871: remote -> us.fatehi:schemacrawler-archetype-plugin-lint (-) Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co ntains): 990: 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-alpha-1 2: 1.0-alpha-2 3: 1.0-alpha-3 4: 1.0-alpha-4 5: 1.0 Choose a number: 5: 5 Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma ven-archetype-webapp/1.0/maven-archetype-webapp-1.0.pom Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav en-archetype-webapp/1.0/maven-archetype-webapp-1.0.pom (533 B at 866 B/s) Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma ven-archetype-bundles/2/maven-archetype-bundles-2.pom Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav en-archetype-bundles/2/maven-archetype-bundles-2.pom (1.5 kB at 2.8 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/mav en-archetype-parent/1/maven-archetype-parent-1.pom Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/mave n-archetype-parent/1/maven-archetype-parent-1.pom (1.3 kB at 2.5 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/ 4/maven-parent-4.pom Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/4 /maven-parent-4.pom (10.0 kB at 19 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/apache/apache/3/apache-3.p om Downloaded: https://repo.maven.apache.org/maven2/org/apache/apache/3/apache-3.po m (3.4 kB at 6.3 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma ven-archetype-webapp/1.0/maven-archetype-webapp-1.0.jar Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav en-archetype-webapp/1.0/maven-archetype-webapp-1.0.jar (3.9 kB at 7.8 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 Old (1.x) Archetype: maven-archetype-webapp:1.0 [INFO] ------------------------------------------------------------------------- --- [INFO] Parameter: basedir, Value: D:maven [INFO] Parameter: package, Value: com.dx.maven_webdemo1 [INFO] Parameter: groupId, Value: com.dx [INFO] Parameter: artifactId, Value: maven_webdemo1 [INFO] Parameter: packageName, Value: com.dx.maven_webdemo1 [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] project created from Old (1.x) Archetype in dir: D:mavenmaven_webdemo1 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:13 min [INFO] Finished at: 2017-06-23T18:37:24+08:00 [INFO] Final Memory: 16M/172M [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:mavenmaven_demo1>mvn compile [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building maven_demo1 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven_demo 1 --- [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.1:compile (default-compile) @ maven_demo1 --- [INFO] Nothing to compile - all classes are up to date [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.147 s [INFO] Finished at: 2017-06-23T18:53:05+08:00 [INFO] Final Memory: 9M/212M [INFO] ------------------------------------------------------------------------
产看目录结构:
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] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven_demo1 --- Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-uti ls/3.0/plexus-utils-3.0.pom Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util s/3.0/plexus-utils-3.0.pom (4.1 kB at 1.5 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/sonatype/spice/spice-paren t/16/spice-parent-16.pom Downloaded: https://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent /16/spice-parent-16.pom (8.4 kB at 6.4 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/sonatype/forge/forge-paren t/5/forge-parent-5.pom Downloaded: https://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent /5/forge-parent-5.pom (8.4 kB at 13 kB/s) Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-uti ls/3.0/plexus-utils-3.0.jar Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util s/3.0/plexus-utils-3.0.jar (226 kB at 93 kB/s) [INFO] Deleting D:mavenmaven_demo1 arget [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 8.575 s [INFO] Finished at: 2017-06-24T04:32:03+08:00 [INFO] Final Memory: 9M/136M [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
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包到本地仓库中)
maven本地仓库:C:UsersAdministrator.m2 epository
D:mavenmaven_demo1>mvn install [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building maven_demo1 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven -surefire-plugin/2.12.4/maven-surefire-plugin-2.12.4.jar [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.1: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:2.6:testResources (default-testResources) @ ma ven_demo1 --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory 。。。 Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/suref ire-junit3/2.12.4/surefire-junit3-2.12.4.jar (26 kB at 24 kB/s) ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.dx.maven_demo1.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven_demo1 --- 。。。 [INFO] Installing D:mavenmaven_demo1pom.xml to C:UsersAdministrator.m2 ep ositorycomdxmaven_demo11.0-SNAPSHOTmaven_demo1-1.0-SNAPSHOT.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 38.062 s [INFO] Finished at: 2017-06-24T04:54:57+08:00 [INFO] Final Memory: 19M/171M [INFO] ------------------------------------------------------------------------ D:mavenmaven_demo1>
生成的jar包在maven仓库的位置为:C:UsersAdministrator.m2 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:2.6:resources (default-resources) @ maven_demo 1 --- [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.1:compile (default-compile) @ maven_demo1 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ma ven_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.1:testCompile (default-testCompile) @ maven_d emo1 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven_demo1 --- [INFO] Surefire report directory: D:mavenmaven_demo1 argetsurefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.dx.maven_demo1.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven_demo1 --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.694 s [INFO] Finished at: 2017-06-24T04:59:57+08:00 [INFO] Final Memory: 11M/150M [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:2.5:clean (default-clean) @ maven_demo1 --- [INFO] Deleting D:mavenmaven_demo1 arget [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven_demo 1 --- [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.1: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:2.6:testResources (default-testResources) @ ma ven_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.1:testCompile (default-testCompile) @ maven_d emo1 --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to D:mavenmaven_demo1 arget est-classes [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven_demo1 --- [INFO] Surefire report directory: D:mavenmaven_demo1 argetsurefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.dx.maven_demo1.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.4: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: 3.643 s [INFO] Finished at: 2017-06-24T05:03:50+08:00 [INFO] Final Memory: 17M/167M [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:2.4:jar (default-cli) @ maven_demo1 --- [WARNING] JAR will be empty - no content was marked for inclusion! [INFO] Building jar: D:mavenmaven_demo1 argetmaven_demo1-1.0-SNAPSHOT.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.305 s [INFO] Finished at: 2017-06-24T05:06:19+08:00 [INFO] Final Memory: 10M/150M [INFO] ------------------------------------------------------------------------ D:mavenmaven_demo1>