Skip to content

Instantly share code, notes, and snippets.

@cshijiel
Created October 31, 2016 07:49
Show Gist options
  • Save cshijiel/e9c8c533220bb83cdab2afd03d9c79ec to your computer and use it in GitHub Desktop.
Save cshijiel/e9c8c533220bb83cdab2afd03d9c79ec to your computer and use it in GitHub Desktop.
Maven 相关命令

背景:有时候只需要编译代码而不需要运行测试代码,这时候就需要下面这个命令。

mvn test-compile

其他:

Maven常用命令:

  1. 创建Maven的普通java项目: mvn archetype:create -DgroupId=packageName -DartifactId=projectName
  2. 创建Maven的Web项目:
    mvn archetype:create -DgroupId=packageName
    -DartifactId=webappName -DarchetypeArtifactId=maven-archetype-webapp
  3. 编译源代码: mvn compile
  4. 编译测试代码:mvn test-compile
  5. 运行测试:mvn test
  6. 产生site:mvn site
  7. 打包:mvn package
  8. 在本地Repository中安装jar:mvn install
  9. 清除产生的项目:mvn clean
  10. 生成eclipse项目:mvn eclipse:eclipse
  11. 生成idea项目:mvn idea:idea
  12. 组合使用goal命令,如只打包不测试:mvn -Dtest package
  13. 编译测试的内容:mvn test-compile
  14. 只打jar包: mvn jar:jar
  15. 只测试而不编译,也不测试编译:mvn test -skipping compile -skipping test-compile ( -skipping 的灵活运用,当然也可以用于其他组合命令)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment