阅读(4431) (0)

Maven命令

2017-01-09 19:18:23 更新

Maven教程 - Maven命令

maven常用命令

  • mvn -version                 查看maven的版本及配置信息
  • mvn archetype:create   -DgroupId=    DartifactId=    构建java项目
  • mvn archetype:create   -DgroupId=    DartifactId=    -DarchetypeArtifactId=maven-archetype-webapp 创建web项目
  • mvn compile                编译项目代码
  • mvn package               打包项目
  • mvn package -Dmaven.test.skip=true   打包项目时跳过单元测试
  • mvn test                      运行单元测试
  • mvn clean                    清除编译产生的target文件夹内容,可以配合相应命令一起使用,如mvn clean package, mvn clean test
  • mvn install                   打包后将其安装在本地仓库
  • mvn deploy                  打包后将其安装到pom文件中配置的远程仓库
  • mvn eclipse:eclipse      将maven生成eclipse项目结构
  • mvn eclipse:clean         清除maven项目中eclipse的项目结构
  • mvn site                       生成站点目录
  • mvn dependency:list      显示所有已经解析的所有依赖
  • mvn dependency:tree     以树的结构展示项目中的依赖
  • mvn dependency:analyze  对项目中的依赖进行分析,依赖未使用,使用单未引入
  • mvn tomcat:run              启动tomcat


我们可以使用Maven在命令中创建应用程序的文档。

c:\mvn_test\xmlFileEditor>mvn site
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building xmlFileEditor 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-site-plugin:3.3:site (default-site) @ xmlFileEditor ---
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/reporting/maven-reporting-exec/1.1/maven-reporting-exec-1.1.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/reporting/maven-reporting-exec/1.1/maven-reporting-exec-1.1.pom (11 KB at 11.4 KB/sec)
Downloading other if necessary
...
...
[WARNING] Report plugin org.apache.maven.plugins:maven-project-info-reports-plugin has an empty version.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/skins/maven-default-skin/1.0/maven-default-skin-1.0.jar (8 KB at 84.9 KB/sec)
Downloading other if necessary
...
...
[INFO] Rendering site with org.apache.maven.skins:maven-default-skin:jar:1.0 skin.
[INFO] Generating "About" report    --- maven-project-info-reports-plugin:2.7
[INFO] Generating "Plugin Management" report    --- maven-project-info-reports-plugin:2.7
[INFO] Generating "Distribution Management" report    --- maven-project-info-reports-plugin:2.7
[INFO] Generating "Dependency Information" report    --- maven-project-info-reports-plugin:2.7
[INFO] Generating "Source Repository" report    --- maven-project-info-reports-plugin:2.7
[INFO] Generating "Mailing Lists" report    --- maven-project-info-reports-plugin:2.7
[INFO] Generating "Issue Tracking" report    --- maven-project-info-reports-plugin:2.7
[INFO] Generating "Continuous Integration" report    --- maven-project-info-reports-plugin:2.7
[INFO] Generating "Project Plugins" report    --- maven-project-info-reports-plugin:2.7
[INFO] Generating "Project License" report    --- maven-project-info-reports-plugin:2.7
[INFO] Generating "Project Team" report    --- maven-project-info-reports-plugin:2.7
[INFO] Generating "Project Summary" report    --- maven-project-info-reports-plugin:2.7
[INFO] Generating "Dependencies" report    --- maven-project-info-reports-plugin:2.7
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:24 min
[INFO] Finished at: 2014-11-22T09:34:18-08:00
[INFO] Final Memory: 28M/369M
[INFO] ------------------------------------------------------------------------

c:\mvn_test\xmlFileEditor>

您的项目文档已准备就绪。Maven已经在目标目录中创建了一个网站。

null

打开c:\\ mvn_test \\ xmlFileEditor \\ target \\ site文件夹。单击index.html查看文档。

null