Java-Maven(二):Maven常用命令
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): : maven-archetype-quickstart #输入骨架名称,可以自动筛选如骨架编号
- Choose archetype:
- : 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 #输入骨架对应的编号
- Choose org.apache.maven.archetypes:maven-archetype-quickstart version:
- : 1.0-alpha-
- : 1.0-alpha-
- : 1.0-alpha-
- : 1.0-alpha-
- : 1.0
- : 1.1
- Choose a number: : 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//maven-archetype-bundles-.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav
- en-archetype-bundles//maven-archetype-bundles-.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-/maven-archetype-2.0-alpha-.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/mave
- n-archetype/2.0-alpha-/maven-archetype-2.0-alpha-.pom (8.7 kB at kB/s)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/
- /maven-parent-.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/1
- /maven-parent-.pom ( kB at 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 ( kB at 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 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 (.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 (.x) Archetype in dir: D:\maven\maven_demo1
- [INFO] -------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] -------------------------------------------------------------
- [INFO] Total time: : min
- [INFO] Finished at: --23T18::+:
- [INFO] Final Memory: 17M/262M
- [INFO] -------------------------------------------------------------
- D:\maven>
此时,在d:\maven\就有一个工程maven_demo1
maven_demo1 java工程的目录结构:
- D:\maven\.
- 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
备注: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
- : remote -> us.fatehi:schemacrawler-archetype-plugin-lint (-)
- Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co
- ntains): : maven-archetype-webapp
- Choose archetype:
- : 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): :
- Choose org.apache.maven.archetypes:maven-archetype-webapp version:
- : 1.0-alpha-
- : 1.0-alpha-
- : 1.0-alpha-
- : 1.0-alpha-
- : 1.0
- Choose a number: :
- 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 ( B at B/s)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/ma
- ven-archetype-bundles//maven-archetype-bundles-.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/mav
- en-archetype-bundles//maven-archetype-bundles-.pom (1.5 kB at 2.8 kB/s)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/mav
- en-archetype-parent//maven-archetype-parent-.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/mave
- n-archetype-parent//maven-archetype-parent-.pom (1.3 kB at 2.5 kB/s)
- Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/
- /maven-parent-.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/4
- /maven-parent-.pom (10.0 kB at 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 (.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 (.x) Archetype in dir: D:\maven\maven_webdemo1
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: : min
- [INFO] Finished at: --23T18::+:
- [INFO] Final Memory: 16M/172M
- [INFO] ------------------------------------------------------------------------
- D:\maven>
查看目录结构:
- D:\maven\maven_webdemo1\.
- D:\maven\maven_webdemo1\pom.xml
- D:\maven\maven_webdemo1\src\.
- D:\maven\maven_webdemo1\src\main\.
- D:\maven\maven_webdemo1\src\main\resources\.
- D:\maven\maven_webdemo1\src\main\webapp\.
- D:\maven\maven_webdemo1\src\main\webapp\index.jsp
- D:\maven\maven_webdemo1\src\main\webapp\WEB-INF\.
- D:\maven\maven_webdemo1\src\main\webapp\WEB-INF\web.xml
3)maven compile
- D:\maven\maven_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
- ---
- [INFO] Using 'UTF-8' encoding to copy filtered resources.
- [INFO] skip non existing resourceDirectory D:\maven\maven_demo1\src\main\resourc
- 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: --23T18::+:
- [INFO] Final Memory: 9M/212M
- [INFO] ------------------------------------------------------------------------
产看目录结构:
- 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\classes\.
- D:\maven\maven_demo1\target\classes\com\.
- D:\maven\maven_demo1\target\classes\com\dx\.
- D:\maven\maven_demo1\target\classes\com\dx\maven_demo1\.
- D:\maven\maven_demo1\target\classes\com\dx\maven_demo1\App.class
- D:\maven\maven_demo1\target\maven-status\.
- D:\maven\maven_demo1\target\maven-status\maven-compiler-plugin\.
- D:\maven\maven_demo1\target\maven-status\maven-compiler-plugin\compile\.
- D:\maven\maven_demo1\target\maven-status\maven-compiler-plugin\compile\default-c
- ompile\.
- D:\maven\maven_demo1\target\maven-status\maven-compiler-plugin\compile\default-c
- ompile\createdFiles.lst
- D:\maven\maven_demo1\target\maven-status\maven-compiler-plugin\compile\default-c
- ompile\inputFiles.lst
4)maven clean
- D:\maven\maven_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//spice-parent-.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/sonatype/spice/spice-parent
- //spice-parent-.pom (8.4 kB at 6.4 kB/s)
- Downloading: https://repo.maven.apache.org/maven2/org/sonatype/forge/forge-paren
- t//forge-parent-.pom
- Downloaded: https://repo.maven.apache.org/maven2/org/sonatype/forge/forge-parent
- //forge-parent-.pom (8.4 kB at 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 ( kB at kB/s)
- [INFO] Deleting D:\maven\maven_demo1\target
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 8.575 s
- [INFO] Finished at: --24T04::+:
- [INFO] Final Memory: 9M/136M
- [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
5)mvn site生成站点目录
- D:\maven\maven_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: --24T04::+:
- [INFO] Final Memory: 21M/276M
- [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
- D:\maven\maven_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./maven-surefire-plugin-2.12..jar
- [INFO] Using 'UTF-8' encoding to copy filtered resources.
- [INFO] skip non existing resourceDirectory D:\maven\maven_demo1\src\main\resourc
- es
- [INFO]
- [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven_demo1 ---
- [INFO] Changes detected - recompiling the module!
- [INFO] Compiling source file to D:\maven\maven_demo1\target\classes
- [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./surefire-junit3-2.12..jar ( kB at kB/s)
- -------------------------------------------------------
- T E S T S
- -------------------------------------------------------
- Running com.dx.maven_demo1.AppTest
- Tests run: , Failures: , Errors: , Skipped: , Time elapsed: 0.005 sec
- Results :
- Tests run: , Failures: , Errors: , Skipped:
- [INFO]
- [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven_demo1 ---
- 。。。
- [INFO] Installing D:\maven\maven_demo1\pom.xml to C:\Users\Administrator\.m2\rep
- ository\com\dx\maven_demo1\1.0-SNAPSHOT\maven_demo1-1.0-SNAPSHOT.pom
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 38.062 s
- [INFO] Finished at: --24T04::+:
- [INFO] Final Memory: 19M/171M
- [INFO] ------------------------------------------------------------------------
- D:\maven\maven_demo1>
生成的jar包在maven仓库的位置为:C:\Users\Administrator\.m2\repository\com\dx\maven_demo1\1.0-SNAPSHOT
7)mvn package(打包)
- D:\maven\maven_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
- ---
- [INFO] Using 'UTF-8' encoding to copy filtered resources.
- [INFO] skip non existing resourceDirectory D:\maven\maven_demo1\src\main\resourc
- 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:\maven\maven_demo1\src\test\resourc
- 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.:test (default-test) @ maven_demo1 ---
- [INFO] Surefire report directory: D:\maven\maven_demo1\target\surefire-reports
- -------------------------------------------------------
- T E S T S
- -------------------------------------------------------
- Running com.dx.maven_demo1.AppTest
- Tests run: , Failures: , Errors: , Skipped: , Time elapsed: 0.004 sec
- Results :
- Tests run: , Failures: , Errors: , Skipped:
- [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: --24T04::+:
- [INFO] Final Memory: 11M/150M
- [INFO] ------------------------------------------------------------------------
- D:\maven\maven_demo1>
打包文件位置:D:\maven\maven_demo1\target\maven_demo1-1.0-SNAPSHOT.jar
在web工程中,会生成*.war包。
8)mvn clean package(先清理再打包)
- D:\maven\maven_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:\maven\maven_demo1\target
- [INFO]
- [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven_demo
- ---
- [INFO] Using 'UTF-8' encoding to copy filtered resources.
- [INFO] skip non existing resourceDirectory D:\maven\maven_demo1\src\main\resourc
- es
- [INFO]
- [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven_demo1 ---
- [INFO] Changes detected - recompiling the module!
- [INFO] Compiling source file to D:\maven\maven_demo1\target\classes
- [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:\maven\maven_demo1\src\test\resourc
- es
- [INFO]
- [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven_d
- emo1 ---
- [INFO] Changes detected - recompiling the module!
- [INFO] Compiling source file to D:\maven\maven_demo1\target\test-classes
- [INFO]
- [INFO] --- maven-surefire-plugin:2.12.:test (default-test) @ maven_demo1 ---
- [INFO] Surefire report directory: D:\maven\maven_demo1\target\surefire-reports
- -------------------------------------------------------
- T E S T S
- -------------------------------------------------------
- Running com.dx.maven_demo1.AppTest
- Tests run: , Failures: , Errors: , Skipped: , Time elapsed: 0.005 sec
- Results :
- Tests run: , Failures: , Errors: , Skipped:
- [INFO]
- [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven_demo1 ---
- [INFO] Building jar: D:\maven\maven_demo1\target\maven_demo1-1.0-SNAPSHOT.jar
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 3.643 s
- [INFO] Finished at: --24T05::+:
- [INFO] Final Memory: 17M/167M
- [INFO] ------------------------------------------------------------------------
- D:\maven\maven_demo1>
9)mvn jar:jar(打包为jar)
- D:\maven\maven_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:\maven\maven_demo1\target\maven_demo1-1.0-SNAPSHOT.jar
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 1.305 s
- [INFO] Finished at: --24T05::+:
- [INFO] Final Memory: 10M/150M
- [INFO] ------------------------------------------------------------------------
- D:\maven\maven_demo1>
Java-Maven(二):Maven常用命令的更多相关文章
- [MAVEN]二、常用命令
mvn eclipse:eclipse :生成 Eclipse 项目文件,生成后可以导入到eclipse中使用 mvn install :在本地 Repository 中安装 jar ,若是Web项目 ...
- docker学习笔记二:常用命令
docker学习笔记二:常用命令 查看docker常用命令 docker --help 返回结果如下: 其中常用的命令如下: 1.image相关操作 展示所有的image: 删除image: rmi ...
- Maven使用笔记(一)Maven安装及常用命令
1.Windows下安装Maven 首先去下载Maven安装包,http://maven.apache.org/download.cgi,目前最新版本是 Maven 3.2.3 . 解压到本地,可以看 ...
- Maven 插件 maven-tomcat7-plugin - 常用命令及配置
常用命令 tomcat7:deploy 说明:部署 WAR 到 Tomcat tomcat7:help 说明:查看插件帮助信息 tomcat7:run 说明:支行当前项目 配置 <project ...
- 【java开发】ubuntu常用命令及环境搭建
学习第一天,今天内容相对简单,主要就是ubuntu一些常用命令及常规操作,后续涉及到环境的搭建,也会在本文再更. ubuntu环境搭建 第一种 也是最简单最方便的 通过vm虚拟机软件,下载iso镜像进 ...
- 大数据入门第十七天——storm上游数据源 之kafka详解(二)常用命令
一.kafka常用命令 1.创建topic bin/kafka-topics. --replication-factor --zookeeper mini1: // 如果配置了PATH可以省略相关命令 ...
- 大数据入门第十六天——流式计算之storm详解(二)常用命令与wc实例
一.常用命令 1.提交命令 提交任务命令格式:storm jar [jar路径] [拓扑包名.拓扑类名] [拓扑名称] torm jar examples/storm-starter/storm-st ...
- Sqoop(二)常用命令及常数解析
一.常用命令列举 二.命令及参数详解 1.数据库连接 2.import 3.export 4.hive
- Docker应用二:docker常用命令介绍
Docker常用命令使用介绍 docker中常用的命令: 1.docker search image_name:搜查镜像 2.docker pull image_name:从镜像库中拉去镜像 3.d ...
- Linux-第二篇常用命令
1.常用目录文件操作命令 cd:切换目录 格式:cd 目录 ls:显示文件和目录列表.可选参数: -l 列出文件的详细信息 -a 列出当前目录所有文件,包含隐藏文件 ll:查看目录接口,相当于是ls ...
随机推荐
- 1-2 Spring 的基本使用
1.Spring容器的配置文件applicationContext.xml的引入 名称可以自己定义 <?xml version="1.0" encoding="UT ...
- Shell 判断文件或文件夹是否存在
#shell判断文件夹是否存在 #如果文件夹不存在,创建文件夹 if [ ! -d "/myfolder" ]; then mkdir /myfolder fi #shell判断文 ...
- linux新建用户并赋管理员权限
输入useradd新建一个用户 [root@java-devenv ~]# useradd yaoqi [root@java-devenv ~]# passwd yaoqi passwd 是修改用户密 ...
- sql模糊查询效率
在数据库量比较大的时候通常有一些查询,例如查询文本类型的数据,存储量大,用like进行模糊查询效率实在太低 select * from stdcontent where content like ' ...
- RESTFUL风格 put 报错 HTTP Status 405 - JSPs only permit GET POST or HEAD
出现下图这种情况时是controller所return的jsp视图找不到, 所以提示请求只允许GET.POST.HEAD. 解决方案 1.若返回视图,把表单中name为_method的input值改为 ...
- Restful风格,PUT修改功能请求,表单中存在文件报错-HTTP Status 405 - Request method 'POST' not supported
解决方案配置如下 <!-- 配置文件上传解析器 --> <bean id="multipartResolver" class="org.springfr ...
- [COGS 2583]南极科考旅行
2583. 南极科考旅行 ★★ 输入文件:BitonicTour.in 输出文件:BitonicTour.out 简单对比时间限制:1 s 内存限制:256 MB [题目描述] 小美要 ...
- Java基础学习笔记二十 IO流
转换流 在学习字符流(FileReader.FileWriter)的时候,其中说如果需要指定编码和缓冲区大小时,可以在字节流的基础上,构造一个InputStreamReader或者OutputStre ...
- Django--基本篇:项目结构与设计模式(MVC)
Django在项目开发中有着结构清晰.层次明显.容易编写理解查阅demo的优点,那么我们来个小案例具体看看. 一.项目结构简析: 我们按照上一篇中的开发流程步骤创建一个新项目myblog,项目下 ...
- 极光征文 | 写写文章就能赢 Filco,岂不美滋滋
由极光社区举办的第二届征文大赛 --「我和极光的那些事儿」又来啦! 在简书平台发布文章并投稿至「我和极光的那些事」专题,只要参与就能 100% 获得京东购物卡,更有机会赢取象征信仰的 Filco 机械 ...