Maven命令简介

Maven提供了一套命令可以用来创建java工程、编译、打包等操作。通过这些命令来处理工作变得更方便、简洁。

Maven工程结构和内容被定义在pom.xml文件中,全称project object moduel

当我们创建一个Maven工程时,Maven会创建默认的工程结构,开发者只需要合理的放置配置文件,而在pom.xml文件中无需做任何配置。

Maven创建工程命令

maven创建工程命令格式:

  1. mvn archetype:generate
  2. -Dgroupid            #公司名称
  3. -DartifactId          #项目名称
  4. -DarchetypeArtifactId    #archetypeArtifactId 模型(骨架)
  5. -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,此时如果你是第一次执行该命令,就会下载很多插件。

当需要下载的内容下载完成后,就开始填写参数等来创建工程

  1. 。。。
    1871: remote -> us.fatehi:schemacrawler-archetype-plugin-lint (-)
  2. Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co
  3. ntains): : maven-archetype-quickstart #输入骨架名称,可以自动筛选如骨架编号
  4. Choose archetype:
  5. : remote -> org.apache.maven.archetypes:maven-archetype-quickstart (An archetyp
  6. e which contains a sample Maven project.)
  7. Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co
  8. ntains): : 1 #输入骨架对应的编号
  9. Choose org.apache.maven.archetypes:maven-archetype-quickstart version:
  10. : 1.0-alpha-
  11. : 1.0-alpha-
  12. : 1.0-alpha-
  13. : 1.0-alpha-
  14. : 1.0
  15. : 1.1
  16. Choose a number: : 6 #输入应用骨架的版本
  17. Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma
  18. ven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.pom
  19. Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav
  20. en-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.pom (2.0 kB at 3.9 kB
  21. /s)
  22. Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma
  23. ven-archetype-bundles//maven-archetype-bundles-.pom
  24. Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav
  25. en-archetype-bundles//maven-archetype-bundles-.pom (3.6 kB at 6.9 kB/s)
  26. Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/mav
  27. en-archetype/2.0-alpha-/maven-archetype-2.0-alpha-.pom
  28. Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/mave
  29. n-archetype/2.0-alpha-/maven-archetype-2.0-alpha-.pom (8.7 kB at kB/s)
  30. Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/
  31. /maven-parent-.pom
  32. Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/1
  33. /maven-parent-.pom ( kB at kB/s)
  34. Downloading: https://repo.maven.apache.org/maven2/org/apache/apache/7/apache-7.p
  35. om
  36. Downloaded: https://repo.maven.apache.org/maven2/org/apache/apache/7/apache-7.po
  37. m ( kB at kB/s)
  38. Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma
  39. ven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.jar
  40. Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav
  41. en-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.jar (6.2 kB at kB/
  42. s)
  43. Define value for property 'groupId': com.dx #为公司名称
  44. Define value for property 'artifactId': maven_demo1 #为项目名称
  45. Define value for property 'version' 1.0-SNAPSHOT: : #项目版本,直接回车为默认1.0-SNAPSHOT
  46. Define value for property 'package' com.dx: : com.dx.maven_demo1#包名
  47. Confirm properties configuration:
  48. groupId: com.dx
  49. artifactId: maven_demo1
  50. version: 1.0-SNAPSHOT
  51. package: com.dx.maven_demo1
  52. Y: : y #确认是否为以上参数
  53. [INFO] --------------------------------------------------------------
  54. [INFO] Using following parameters for creating project from Old (.x) Archetype:
  55. maven-archetype-quickstart:1.1
  56. [INFO] --------------------------------------------------------------
  57. [INFO] Parameter: basedir, Value: D:\maven
  58. [INFO] Parameter: package, Value: com.dx.maven_demo1
  59. [INFO] Parameter: groupId, Value: com.dx
  60. [INFO] Parameter: artifactId, Value: maven_demo1
  61. [INFO] Parameter: packageName, Value: com.dx.maven_demo1
  62. [INFO] Parameter: version, Value: 1.0-SNAPSHOT
  63. [INFO] project created from Old (.x) Archetype in dir: D:\maven\maven_demo1
  64. [INFO] -------------------------------------------------------------
  65. [INFO] BUILD SUCCESS
  66. [INFO] -------------------------------------------------------------
  67. [INFO] Total time: : min
  68. [INFO] Finished at: --23T18::+:
  69. [INFO] Final Memory: 17M/262M
  70. [INFO] -------------------------------------------------------------
  71.  
  72. D:\maven>

此时,在d:\maven\就有一个工程maven_demo1

maven_demo1 java工程的目录结构:

  1. D:\maven\.
  2. D:\maven\maven_demo1\.
  3. D:\maven\maven_demo1\pom.xml
  4. D:\maven\maven_demo1\src\.
  5. D:\maven\maven_demo1\src\main\.
  6. D:\maven\maven_demo1\src\main\java\.
  7. D:\maven\maven_demo1\src\main\java\com\.
  8. D:\maven\maven_demo1\src\main\java\com\dx\.
  9. D:\maven\maven_demo1\src\main\java\com\dx\maven_demo1\.
  10. D:\maven\maven_demo1\src\main\java\com\dx\maven_demo1\App.java
  11. D:\maven\maven_demo1\src\test\.
  12. D:\maven\maven_demo1\src\test\java\.
  13. D:\maven\maven_demo1\src\test\java\com\.
  14. D:\maven\maven_demo1\src\test\java\com\dx\.
  15. D:\maven\maven_demo1\src\test\java\com\dx\maven_demo1\.
  16. D:\maven\maven_demo1\src\test\java\com\dx\maven_demo1\AppTest.java

备注:bat来遍历d:\maven目录

  1. @echo off set work_path=D:\maven
  2. D:
  3. cd %work_path%
  4. for /R %%s in (.,*) do (
  5.   echo %%s
  6. )
  7. pause

2)使用maven-archetype-webapp骨架来创建web project

  1. : remote -> us.fatehi:schemacrawler-archetype-plugin-lint (-)
  2. Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co
  3. ntains): : maven-archetype-webapp
  4. Choose archetype:
  5. : remote -> org.apache.maven.archetypes:maven-archetype-webapp (An archetype wh
  6. ich contains a sample Maven Webapp project.)
  7. Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co
  8. ntains): :
  9. Choose org.apache.maven.archetypes:maven-archetype-webapp version:
  10. : 1.0-alpha-
  11. : 1.0-alpha-
  12. : 1.0-alpha-
  13. : 1.0-alpha-
  14. : 1.0
  15. Choose a number: :
  16. Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma
  17. ven-archetype-webapp/1.0/maven-archetype-webapp-1.0.pom
  18. Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav
  19. en-archetype-webapp/1.0/maven-archetype-webapp-1.0.pom ( B at B/s)
  20. Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma
  21. ven-archetype-bundles//maven-archetype-bundles-.pom
  22. Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav
  23. en-archetype-bundles//maven-archetype-bundles-.pom (1.5 kB at 2.8 kB/s)
  24. Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/mav
  25. en-archetype-parent//maven-archetype-parent-.pom
  26. Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/mave
  27. n-archetype-parent//maven-archetype-parent-.pom (1.3 kB at 2.5 kB/s)
  28. Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/
  29. /maven-parent-.pom
  30. Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/4
  31. /maven-parent-.pom (10.0 kB at kB/s)
  32. Downloading: https://repo.maven.apache.org/maven2/org/apache/apache/3/apache-3.p
  33. om
  34. Downloaded: https://repo.maven.apache.org/maven2/org/apache/apache/3/apache-3.po
  35. m (3.4 kB at 6.3 kB/s)
  36. Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma
  37. ven-archetype-webapp/1.0/maven-archetype-webapp-1.0.jar
  38. Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav
  39. en-archetype-webapp/1.0/maven-archetype-webapp-1.0.jar (3.9 kB at 7.8 kB/s)
  40. Define value for property 'groupId': com.dx
  41. Define value for property 'artifactId': maven_webdemo1
  42. Define value for property 'version' 1.0-SNAPSHOT: :
  43. Define value for property 'package' com.dx: : com.dx.maven_webdemo1
  44. Confirm properties configuration:
  45. groupId: com.dx
  46. artifactId: maven_webdemo1
  47. version: 1.0-SNAPSHOT
  48. package: com.dx.maven_webdemo1
  49. Y: : y
  50. [INFO] -------------------------------------------------------------------------
  51. ---
  52. [INFO] Using following parameters for creating project from Old (.x) Archetype:
  53. maven-archetype-webapp:1.0
  54. [INFO] -------------------------------------------------------------------------
  55. ---
  56. [INFO] Parameter: basedir, Value: D:\maven
  57. [INFO] Parameter: package, Value: com.dx.maven_webdemo1
  58. [INFO] Parameter: groupId, Value: com.dx
  59. [INFO] Parameter: artifactId, Value: maven_webdemo1
  60. [INFO] Parameter: packageName, Value: com.dx.maven_webdemo1
  61. [INFO] Parameter: version, Value: 1.0-SNAPSHOT
  62. [INFO] project created from Old (.x) Archetype in dir: D:\maven\maven_webdemo1
  63. [INFO] ------------------------------------------------------------------------
  64. [INFO] BUILD SUCCESS
  65. [INFO] ------------------------------------------------------------------------
  66. [INFO] Total time: : min
  67. [INFO] Finished at: --23T18::+:
  68. [INFO] Final Memory: 16M/172M
  69. [INFO] ------------------------------------------------------------------------
  70.  
  71. D:\maven>

查看目录结构:

  1. D:\maven\maven_webdemo1\.
  2. D:\maven\maven_webdemo1\pom.xml
  3. D:\maven\maven_webdemo1\src\.
  4. D:\maven\maven_webdemo1\src\main\.
  5. D:\maven\maven_webdemo1\src\main\resources\.
  6. D:\maven\maven_webdemo1\src\main\webapp\.
  7. D:\maven\maven_webdemo1\src\main\webapp\index.jsp
  8. D:\maven\maven_webdemo1\src\main\webapp\WEB-INF\.
  9. D:\maven\maven_webdemo1\src\main\webapp\WEB-INF\web.xml

3)maven compile

  1. D:\maven\maven_demo1>mvn compile
  2. [INFO] Scanning for projects...
  3. [INFO]
  4. [INFO] ------------------------------------------------------------------------
  5. [INFO] Building maven_demo1 1.0-SNAPSHOT
  6. [INFO] ------------------------------------------------------------------------
  7. [INFO]
  8. [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven_demo
  9. ---
  10. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  11. [INFO] skip non existing resourceDirectory D:\maven\maven_demo1\src\main\resourc
  12. es
  13. [INFO]
  14. [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven_demo1 ---
  15.  
  16. [INFO] Nothing to compile - all classes are up to date
  17. [INFO] ------------------------------------------------------------------------
  18. [INFO] BUILD SUCCESS
  19. [INFO] ------------------------------------------------------------------------
  20. [INFO] Total time: 1.147 s
  21. [INFO] Finished at: --23T18::+:
  22. [INFO] Final Memory: 9M/212M
  23. [INFO] ------------------------------------------------------------------------

产看目录结构:

  1. D:\maven\maven_demo1\src\test\java\com\dx\.
  1. D:\maven\maven_demo1\src\test\java\com\dx\maven_demo1\.
  2. D:\maven\maven_demo1\src\test\java\com\dx\maven_demo1\AppTest.java
  3. D:\maven\maven_demo1\target\.
  4. D:\maven\maven_demo1\target\classes\.
  5. D:\maven\maven_demo1\target\classes\com\.
  6. D:\maven\maven_demo1\target\classes\com\dx\.
  7. D:\maven\maven_demo1\target\classes\com\dx\maven_demo1\.
  8. D:\maven\maven_demo1\target\classes\com\dx\maven_demo1\App.class
  9. D:\maven\maven_demo1\target\maven-status\.
  10. D:\maven\maven_demo1\target\maven-status\maven-compiler-plugin\.
  11. D:\maven\maven_demo1\target\maven-status\maven-compiler-plugin\compile\.
  12. D:\maven\maven_demo1\target\maven-status\maven-compiler-plugin\compile\default-c
  13. ompile\.
  14. D:\maven\maven_demo1\target\maven-status\maven-compiler-plugin\compile\default-c
  15. ompile\createdFiles.lst
  16. D:\maven\maven_demo1\target\maven-status\maven-compiler-plugin\compile\default-c
  17. ompile\inputFiles.lst

4)maven clean

  1. D:\maven\maven_demo1>mvn clean
  2. [INFO] Scanning for projects...
  3. [INFO]
  4. [INFO] ------------------------------------------------------------------------
  5. [INFO] Building maven_demo1 1.0-SNAPSHOT
  6. [INFO] ------------------------------------------------------------------------
  7. [INFO]
  8. [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven_demo1 ---
  9. Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-uti
  10. ls/3.0/plexus-utils-3.0.pom
  11. Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
  12. s/3.0/plexus-utils-3.0.pom (4.1 kB at 1.5 kB/s)
  13. Downloading: https://repo.maven.apache.org/maven2/org/sonatype/spice/spice-paren
  14. t//spice-parent-.pom
  15. Downloaded: https://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent
  16. //spice-parent-.pom (8.4 kB at 6.4 kB/s)
  17. Downloading: https://repo.maven.apache.org/maven2/org/sonatype/forge/forge-paren
  18. t//forge-parent-.pom
  19. Downloaded: https://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent
  20. //forge-parent-.pom (8.4 kB at kB/s)
  21. Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-uti
  22. ls/3.0/plexus-utils-3.0.jar
  23. Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
  24. s/3.0/plexus-utils-3.0.jar ( kB at kB/s)
  25. [INFO] Deleting D:\maven\maven_demo1\target
  26. [INFO] ------------------------------------------------------------------------
  27. [INFO] BUILD SUCCESS
  28. [INFO] ------------------------------------------------------------------------
  29. [INFO] Total time: 8.575 s
  30. [INFO] Finished at: --24T04::+:
  31. [INFO] Final Memory: 9M/136M
  32. [INFO] ------------------------------------------------------------------------

查看目录结构:

  1. D:\maven\maven_demo1\.
  2. D:\maven\maven_demo1\pom.xml
  3. D:\maven\maven_demo1\src\.
  4. D:\maven\maven_demo1\src\main\.
  5. D:\maven\maven_demo1\src\main\java\.
  6. D:\maven\maven_demo1\src\main\java\com\.
  7. D:\maven\maven_demo1\src\main\java\com\dx\.
  8. D:\maven\maven_demo1\src\main\java\com\dx\maven_demo1\.
  9. D:\maven\maven_demo1\src\main\java\com\dx\maven_demo1\App.java
  10. D:\maven\maven_demo1\src\test\.
  11. D:\maven\maven_demo1\src\test\java\.
  12. D:\maven\maven_demo1\src\test\java\com\.
  13. D:\maven\maven_demo1\src\test\java\com\dx\.
  14. D:\maven\maven_demo1\src\test\java\com\dx\maven_demo1\.
  15. D:\maven\maven_demo1\src\test\java\com\dx\maven_demo1\AppTest.java

5)mvn site生成站点目录

  1. D:\maven\maven_demo1>mvn site
  2. [INFO] Scanning for projects...
  3. [INFO]
  4. [INFO] ------------------------------------------------------------------------
  5. [INFO] Building maven_demo1 1.0-SNAPSHOT
  6. [INFO] ------------------------------------------------------------------------
  7. [INFO]
  8. [INFO] --- maven-site-plugin:3.3:site (default-site) @ maven_demo1 ---
  9. [WARNING] Report plugin org.apache.maven.plugins:maven-project-info-reports-plug
  10. in has an empty version.
  11. [WARNING]
  12. [WARNING] It is highly recommended to fix these problems because they threaten t
  13. he stability of your build.
  14. [WARNING]
  15. [WARNING] For this reason, future Maven versions might no longer support buildin
  16. g such malformed projects.
  17. [INFO] configuring report plugin org.apache.maven.plugins:maven-project-info-rep
  18. orts-plugin:2.9
  19. [INFO] Relativizing decoration links with respect to project URL: http://maven.a
  20. pache.org
  21. [INFO] Rendering site with org.apache.maven.skins:maven-default-skin:jar:1.0 ski
  22. n.
  23. [INFO] Generating "Dependencies" report --- maven-project-info-reports-plugin
  24. :2.9
  25. [INFO] Generating "Dependency Convergence" report --- maven-project-info-repo
  26. rts-plugin:2.9
  27. [INFO] Generating "Dependency Information" report --- maven-project-info-repo
  28. rts-plugin:2.9
  29. [INFO] Generating "About" report --- maven-project-info-reports-plugin:2.9
  30. [INFO] Generating "Plugin Management" report --- maven-project-info-reports-p
  31. lugin:2.9
  32. [INFO] Generating "Plugins" report --- maven-project-info-reports-plugin:2.9
  33. [INFO] Generating "Summary" report --- maven-project-info-reports-plugin:2.9
  34. [INFO] ------------------------------------------------------------------------
  35. [INFO] BUILD SUCCESS
  36. [INFO] ------------------------------------------------------------------------
  37. [INFO] Total time: 13.808 s
  38. [INFO] Finished at: --24T04::+:
  39. [INFO] Final Memory: 21M/276M
  40. [INFO] ------------------------------------------------------------------------

查看目录结构:

D:\maven\maven_demo1\.
D:\maven\maven_demo1\pom.xml
D:\maven\maven_demo1\src\.
D:\maven\maven_demo1\src\main\.
D:\maven\maven_demo1\src\main\java\.
D:\maven\maven_demo1\src\main\java\com\.
D:\maven\maven_demo1\src\main\java\com\dx\.
D:\maven\maven_demo1\src\main\java\com\dx\maven_demo1\.
D:\maven\maven_demo1\src\main\java\com\dx\maven_demo1\App.java
D:\maven\maven_demo1\src\test\.
D:\maven\maven_demo1\src\test\java\.
D:\maven\maven_demo1\src\test\java\com\.
D:\maven\maven_demo1\src\test\java\com\dx\.
D:\maven\maven_demo1\src\test\java\com\dx\maven_demo1\.
D:\maven\maven_demo1\src\test\java\com\dx\maven_demo1\AppTest.java
D:\maven\maven_demo1\target\.
D:\maven\maven_demo1\target\site\.
D:\maven\maven_demo1\target\site\dependencies.html
D:\maven\maven_demo1\target\site\dependency-convergence.html
D:\maven\maven_demo1\target\site\dependency-info.html
D:\maven\maven_demo1\target\site\index.html
D:\maven\maven_demo1\target\site\plugin-management.html
D:\maven\maven_demo1\target\site\plugins.html
D:\maven\maven_demo1\target\site\project-info.html
D:\maven\maven_demo1\target\site\project-summary.html
D:\maven\maven_demo1\target\site\css\.
D:\maven\maven_demo1\target\site\css\maven-base.css
D:\maven\maven_demo1\target\site\css\maven-theme.css
D:\maven\maven_demo1\target\site\css\print.css
D:\maven\maven_demo1\target\site\css\site.css
D:\maven\maven_demo1\target\site\images\.
D:\maven\maven_demo1\target\site\images\close.gif
D:\maven\maven_demo1\target\site\images\collapsed.gif
D:\maven\maven_demo1\target\site\images\expanded.gif
D:\maven\maven_demo1\target\site\images\external.png
D:\maven\maven_demo1\target\site\images\icon_error_sml.gif
D:\maven\maven_demo1\target\site\images\icon_info_sml.gif
D:\maven\maven_demo1\target\site\images\icon_success_sml.gif
D:\maven\maven_demo1\target\site\images\icon_warning_sml.gif
D:\maven\maven_demo1\target\site\images\newwindow.png
D:\maven\maven_demo1\target\site\images\logos\.
D:\maven\maven_demo1\target\site\images\logos\build-by-maven-black.png
D:\maven\maven_demo1\target\site\images\logos\build-by-maven-white.png
D:\maven\maven_demo1\target\site\images\logos\maven-feather.png

其中可以访问D:\maven\maven_demo1\target\site\index.html,页面结果为:

6)mvn install(把当前工程生成war或者jar包到本地仓库中)

maven本地仓库:C:\Users\Administrator\.m2\repository

  1. D:\maven\maven_demo1>mvn install
  2. [INFO] Scanning for projects...
  3. [INFO]
  4. [INFO] ------------------------------------------------------------------------
  5. [INFO] Building maven_demo1 1.0-SNAPSHOT
  6. [INFO] ------------------------------------------------------------------------
  7. Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
  8. -surefire-plugin/2.12./maven-surefire-plugin-2.12..jar
  9. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  10. [INFO] skip non existing resourceDirectory D:\maven\maven_demo1\src\main\resourc
  11. es
  12. [INFO]
  13. [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven_demo1 ---
  14.  
  15. [INFO] Changes detected - recompiling the module!
  16. [INFO] Compiling source file to D:\maven\maven_demo1\target\classes
  17. [INFO]
  18. [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ma
  19. ven_demo1 ---
  20. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  21. [INFO] skip non existing resourceDirectory
  22. 。。。
  23. Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/suref
  24. ire-junit3/2.12./surefire-junit3-2.12..jar ( kB at kB/s)
  25.  
  26. -------------------------------------------------------
  27. T E S T S
  28. -------------------------------------------------------
  29. Running com.dx.maven_demo1.AppTest
  30. Tests run: , Failures: , Errors: , Skipped: , Time elapsed: 0.005 sec
  31.  
  32. Results :
  33.  
  34. Tests run: , Failures: , Errors: , Skipped:
  35.  
  36. [INFO]
  37. [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven_demo1 ---
  38. 。。。
  39. [INFO] Installing D:\maven\maven_demo1\pom.xml to C:\Users\Administrator\.m2\rep
  40. ository\com\dx\maven_demo1\1.0-SNAPSHOT\maven_demo1-1.0-SNAPSHOT.pom
  41. [INFO] ------------------------------------------------------------------------
  42. [INFO] BUILD SUCCESS
  43. [INFO] ------------------------------------------------------------------------
  44. [INFO] Total time: 38.062 s
  45. [INFO] Finished at: --24T04::+:
  46. [INFO] Final Memory: 19M/171M
  47. [INFO] ------------------------------------------------------------------------
  48.  
  49. D:\maven\maven_demo1>

生成的jar包在maven仓库的位置为:C:\Users\Administrator\.m2\repository\com\dx\maven_demo1\1.0-SNAPSHOT

7)mvn package(打包)

  1. D:\maven\maven_demo1>mvn package
  2. [INFO] Scanning for projects...
  3. [INFO]
  4. [INFO] ------------------------------------------------------------------------
  5. [INFO] Building maven_demo1 1.0-SNAPSHOT
  6. [INFO] ------------------------------------------------------------------------
  7. [INFO]
  8. [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven_demo
  9. ---
  10. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  11. [INFO] skip non existing resourceDirectory D:\maven\maven_demo1\src\main\resourc
  12. es
  13. [INFO]
  14. [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven_demo1 ---
  15.  
  16. [INFO] Nothing to compile - all classes are up to date
  17. [INFO]
  18. [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ma
  19. ven_demo1 ---
  20. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  21. [INFO] skip non existing resourceDirectory D:\maven\maven_demo1\src\test\resourc
  22. es
  23. [INFO]
  24. [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven_d
  25. emo1 ---
  26. [INFO] Nothing to compile - all classes are up to date
  27. [INFO]
  28. [INFO] --- maven-surefire-plugin:2.12.:test (default-test) @ maven_demo1 ---
  29. [INFO] Surefire report directory: D:\maven\maven_demo1\target\surefire-reports
  30.  
  31. -------------------------------------------------------
  32. T E S T S
  33. -------------------------------------------------------
  34. Running com.dx.maven_demo1.AppTest
  35. Tests run: , Failures: , Errors: , Skipped: , Time elapsed: 0.004 sec
  36.  
  37. Results :
  38.  
  39. Tests run: , Failures: , Errors: , Skipped:
  40.  
  41. [INFO]
  42. [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven_demo1 ---
  43. [INFO] ------------------------------------------------------------------------
  44. [INFO] BUILD SUCCESS
  45. [INFO] ------------------------------------------------------------------------
  46. [INFO] Total time: 2.694 s
  47. [INFO] Finished at: --24T04::+:
  48. [INFO] Final Memory: 11M/150M
  49. [INFO] ------------------------------------------------------------------------
  50.  
  51. D:\maven\maven_demo1>

打包文件位置:D:\maven\maven_demo1\target\maven_demo1-1.0-SNAPSHOT.jar

在web工程中,会生成*.war包。

8)mvn clean package(先清理再打包)

  1. D:\maven\maven_demo1>mvn clean package
  2. [INFO] Scanning for projects...
  3. [INFO]
  4. [INFO] ------------------------------------------------------------------------
  5. [INFO] Building maven_demo1 1.0-SNAPSHOT
  6. [INFO] ------------------------------------------------------------------------
  7. [INFO]
  8. [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven_demo1 ---
  9. [INFO] Deleting D:\maven\maven_demo1\target
  10. [INFO]
  11. [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven_demo
  12. ---
  13. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  14. [INFO] skip non existing resourceDirectory D:\maven\maven_demo1\src\main\resourc
  15. es
  16. [INFO]
  17. [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven_demo1 ---
  18.  
  19. [INFO] Changes detected - recompiling the module!
  20. [INFO] Compiling source file to D:\maven\maven_demo1\target\classes
  21. [INFO]
  22. [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ma
  23. ven_demo1 ---
  24. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  25. [INFO] skip non existing resourceDirectory D:\maven\maven_demo1\src\test\resourc
  26. es
  27. [INFO]
  28. [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven_d
  29. emo1 ---
  30. [INFO] Changes detected - recompiling the module!
  31. [INFO] Compiling source file to D:\maven\maven_demo1\target\test-classes
  32. [INFO]
  33. [INFO] --- maven-surefire-plugin:2.12.:test (default-test) @ maven_demo1 ---
  34. [INFO] Surefire report directory: D:\maven\maven_demo1\target\surefire-reports
  35.  
  36. -------------------------------------------------------
  37. T E S T S
  38. -------------------------------------------------------
  39. Running com.dx.maven_demo1.AppTest
  40. Tests run: , Failures: , Errors: , Skipped: , Time elapsed: 0.005 sec
  41.  
  42. Results :
  43.  
  44. Tests run: , Failures: , Errors: , Skipped:
  45.  
  46. [INFO]
  47. [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven_demo1 ---
  48. [INFO] Building jar: D:\maven\maven_demo1\target\maven_demo1-1.0-SNAPSHOT.jar
  49. [INFO] ------------------------------------------------------------------------
  50. [INFO] BUILD SUCCESS
  51. [INFO] ------------------------------------------------------------------------
  52. [INFO] Total time: 3.643 s
  53. [INFO] Finished at: --24T05::+:
  54. [INFO] Final Memory: 17M/167M
  55. [INFO] ------------------------------------------------------------------------
  56.  
  57. D:\maven\maven_demo1>

9)mvn jar:jar(打包为jar)

  1. D:\maven\maven_demo1>mvn jar:jar
  2. [INFO] Scanning for projects...
  3. [INFO]
  4. [INFO] ------------------------------------------------------------------------
  5. [INFO] Building maven_demo1 1.0-SNAPSHOT
  6. [INFO] ------------------------------------------------------------------------
  7. [INFO]
  8. [INFO] --- maven-jar-plugin:2.4:jar (default-cli) @ maven_demo1 ---
  9. [WARNING] JAR will be empty - no content was marked for inclusion!
  10. [INFO] Building jar: D:\maven\maven_demo1\target\maven_demo1-1.0-SNAPSHOT.jar
  11. [INFO] ------------------------------------------------------------------------
  12. [INFO] BUILD SUCCESS
  13. [INFO] ------------------------------------------------------------------------
  14. [INFO] Total time: 1.305 s
  15. [INFO] Finished at: --24T05::+:
  16. [INFO] Final Memory: 10M/150M
  17. [INFO] ------------------------------------------------------------------------
  18.  
  19. D:\maven\maven_demo1>

Java-Maven(二):Maven常用命令的更多相关文章

  1. [MAVEN]二、常用命令

    mvn eclipse:eclipse :生成 Eclipse 项目文件,生成后可以导入到eclipse中使用 mvn install :在本地 Repository 中安装 jar ,若是Web项目 ...

  2. docker学习笔记二:常用命令

    docker学习笔记二:常用命令 查看docker常用命令 docker --help 返回结果如下: 其中常用的命令如下: 1.image相关操作 展示所有的image: 删除image: rmi ...

  3. Maven使用笔记(一)Maven安装及常用命令

    1.Windows下安装Maven 首先去下载Maven安装包,http://maven.apache.org/download.cgi,目前最新版本是 Maven 3.2.3 . 解压到本地,可以看 ...

  4. Maven 插件 maven-tomcat7-plugin - 常用命令及配置

    常用命令 tomcat7:deploy 说明:部署 WAR 到 Tomcat tomcat7:help 说明:查看插件帮助信息 tomcat7:run 说明:支行当前项目 配置 <project ...

  5. 【java开发】ubuntu常用命令及环境搭建

    学习第一天,今天内容相对简单,主要就是ubuntu一些常用命令及常规操作,后续涉及到环境的搭建,也会在本文再更. ubuntu环境搭建 第一种 也是最简单最方便的 通过vm虚拟机软件,下载iso镜像进 ...

  6. 大数据入门第十七天——storm上游数据源 之kafka详解(二)常用命令

    一.kafka常用命令 1.创建topic bin/kafka-topics. --replication-factor --zookeeper mini1: // 如果配置了PATH可以省略相关命令 ...

  7. 大数据入门第十六天——流式计算之storm详解(二)常用命令与wc实例

    一.常用命令 1.提交命令 提交任务命令格式:storm jar [jar路径] [拓扑包名.拓扑类名] [拓扑名称] torm jar examples/storm-starter/storm-st ...

  8. Sqoop(二)常用命令及常数解析

    一.常用命令列举 二.命令及参数详解 1.数据库连接 2.import 3.export 4.hive

  9. Docker应用二:docker常用命令介绍

     Docker常用命令使用介绍 docker中常用的命令: 1.docker search image_name:搜查镜像 2.docker pull image_name:从镜像库中拉去镜像 3.d ...

  10. Linux-第二篇常用命令

    1.常用目录文件操作命令 cd:切换目录 格式:cd 目录 ls:显示文件和目录列表.可选参数: -l 列出文件的详细信息 -a 列出当前目录所有文件,包含隐藏文件 ll:查看目录接口,相当于是ls ...

随机推荐

  1. 1-2 Spring 的基本使用

    1.Spring容器的配置文件applicationContext.xml的引入 名称可以自己定义 <?xml version="1.0" encoding="UT ...

  2. Shell 判断文件或文件夹是否存在

    #shell判断文件夹是否存在 #如果文件夹不存在,创建文件夹 if [ ! -d "/myfolder" ]; then mkdir /myfolder fi #shell判断文 ...

  3. linux新建用户并赋管理员权限

    输入useradd新建一个用户 [root@java-devenv ~]# useradd yaoqi [root@java-devenv ~]# passwd yaoqi passwd 是修改用户密 ...

  4. sql模糊查询效率

    在数据库量比较大的时候通常有一些查询,例如查询文本类型的数据,存储量大,用like进行模糊查询效率实在太低 select * from stdcontent where  content like ' ...

  5. RESTFUL风格 put 报错 HTTP Status 405 - JSPs only permit GET POST or HEAD

    出现下图这种情况时是controller所return的jsp视图找不到, 所以提示请求只允许GET.POST.HEAD. 解决方案 1.若返回视图,把表单中name为_method的input值改为 ...

  6. Restful风格,PUT修改功能请求,表单中存在文件报错-HTTP Status 405 - Request method 'POST' not supported

    解决方案配置如下 <!-- 配置文件上传解析器 --> <bean id="multipartResolver" class="org.springfr ...

  7. [COGS 2583]南极科考旅行

    2583. 南极科考旅行 ★★   输入文件:BitonicTour.in   输出文件:BitonicTour.out   简单对比时间限制:1 s   内存限制:256 MB [题目描述] 小美要 ...

  8. Java基础学习笔记二十 IO流

    转换流 在学习字符流(FileReader.FileWriter)的时候,其中说如果需要指定编码和缓冲区大小时,可以在字节流的基础上,构造一个InputStreamReader或者OutputStre ...

  9. Django--基本篇:项目结构与设计模式(MVC)

    Django在项目开发中有着结构清晰.层次明显.容易编写理解查阅demo的优点,那么我们来个小案例具体看看.    一.项目结构简析: 我们按照上一篇中的开发流程步骤创建一个新项目myblog,项目下 ...

  10. 极光征文 | 写写文章就能赢 Filco,岂不美滋滋

    由极光社区举办的第二届征文大赛 --「我和极光的那些事儿」又来啦! 在简书平台发布文章并投稿至「我和极光的那些事」专题,只要参与就能 100% 获得京东购物卡,更有机会赢取象征信仰的 Filco 机械 ...