下面列举了一些常用的
maven
命令,需要注意的是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
的灵活运用,当然也可以用于其他组合命令)
16. 清除eclipse的一些系统设置
mvn eclipse:clean
mvn -e
17. 显示详细错误信息
mvn validate
18. 验证工程是否正确,所有需要的资源是否可用。
mvn test-compile
19. 编译项目测试代码。
mvn integration-test
20. 在集成测试可以运行的环境中处理和发布包
mvn verify
21. 运行任何检查,验证包是否有效且达到质量标准。
mvn generate-sources
附录:
1. 在应用程序用使用多个存储库
<repositories>
<repository>
<id>Ibiblio</id>
<name>Ibiblio</name>
<url>http://www.ibiblio.org/maven/</url>
</repository>
<repository>
<id>PlanetMirror</id>
<name>Planet Mirror</name>
<url>http://public.planetmirror.com/pub/maven/</url>
</repository>
</repositories>
2.部署发布jar到指定仓库
mvn deploy:deploy-file -DgroupId=com -DartifactId=client -Dversion=0.1.0 -Dpackaging=jar -Dfile=d:/client-0.1.0.jar -DrepositoryId=maven-repository-inner -Durl=ftp://xxxxxxx/opt/maven/repository/
3. 发布第三方Jar到本地库中
mvn install:install-file -DgroupId=com -DartifactId=client -Dversion=0.1.0 -Dpackaging=jar -Dfile=d:/client-0.1.0.jar
-DdownloadSources=true
-DdownloadJavadocs=true
公众号ID:longjiazuoA

未经允许不得转载:人生设计师 » Maven常用命令总结