zoukankan      html  css  js  c++  java
  • Maven命令简介:更好更快地管理项目

    最近学习Maven,发现其真的很强大,所以学一点也记一点。
    使用Maven的最大好处在于:生成工程骨架和管理JAR包依赖。

     

    Maven自带了很多的工程骨架,想自定义骨架可以使用交互式命令:

    Xml代码  收藏代码
    1. mvn archetype:generate  

     

    我的是Maven 2.2.1版本,系统自带的骨架一共有41个:

    Xml代码  收藏代码
    1. 1: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web application with Hibernate, Spring and JSF)  
    2. 2: internal -> appfuse-basic-spring (AppFuse archetype for creating a web application with Hibernate, Spring and Spring MVC)  
    3. 3: internal -> appfuse-basic-struts (AppFuse archetype for creating a web application with Hibernate, Spring and Struts 2)  
    4. 4: internal -> appfuse-basic-tapestry (AppFuse archetype for creating a web application with Hibernate, Spring and Tapestry 4)  
    5. 5: internal -> appfuse-core (AppFuse archetype for creating a jar application with Hibernate and Spring and XFire)  
    6. 6: internal -> appfuse-modular-jsf (AppFuse archetype for creating a modular application with Hibernate, Spring and JSF)  
    7. 7: internal -> appfuse-modular-spring (AppFuse archetype for creating a modularapplication with Hibernate, Spring and Spring MVC)  
    8. 8: internal -> appfuse-modular-struts (AppFuse archetype for creating a modularapplication with Hibernate, Spring and Struts 2)  
    9. 9: internal -> appfuse-modular-tapestry (AppFuse archetype for creating a modular application with Hibernate, Spring and Tapestry 4)  
    10. 10: internal -> maven-archetype-j2ee-simple (A simple J2EE Java application)  
    11. 11: internal -> maven-archetype-marmalade-mojo (A Maven plugin development project using marmalade)  
    12. 12: internal -> maven-archetype-mojo (A Maven Java plugin development project)  
    13. 13: internal -> maven-archetype-portlet (A simple portlet application)  
    14. 14: internal -> maven-archetype-profiles ()  
    15. 15: internal -> maven-archetype-quickstart ()  
    16. 16: internal -> maven-archetype-site-simple (A simple site generation project)  
    17. 17: internal -> maven-archetype-site (A more complex site project)  
    18. 18: internal -> maven-archetype-webapp (A simple Java web application)  
    19. 19: internal -> jini-service-archetype (Archetype for Jini service project creation)  
    20. 20: internal -> softeu-archetype-seam (JSF+Facelets+Seam Archetype)  
    21. 21: internal -> softeu-archetype-seam-simple (JSF+Facelets+Seam (no persistence) Archetype)  
    22. 22: internal -> softeu-archetype-jsf (JSF+Facelets Archetype)  
    23. 23: internal -> jpa-maven-archetype (JPA application)  
    24. 24: internal -> spring-osgi-bundle-archetype (Spring-OSGi archetype)  
    25. 25: internal -> confluence-plugin-archetype (Atlassian Confluence plugin archetype)  
    26. 26: internal -> jira-plugin-archetype (Atlassian JIRA plugin archetype)  
    27. 27: internal -> maven-archetype-har (Hibernate Archive)  
    28. 28: internal -> maven-archetype-sar (JBoss Service Archive)  
    29. 29: internal -> wicket-archetype-quickstart (A simple Apache Wicket project)  
    30. 30: internal -> scala-archetype-simple (A simple scala project)  
    31. 31: internal -> lift-archetype-blank (A blank/empty liftweb project)  
    32. 32: internal -> lift-archetype-basic (The basic (liftweb) project)  
    33. 33: internal -> cocoon-22-archetype-block-plain ([http://cocoon.apache.org/2.2/maven-plugins/])  
    34. 34: internal -> cocoon-22-archetype-block ([http://cocoon.apache.org/2.2/maven-plugins/])  
    35. 35: internal -> cocoon-22-archetype-webapp ([http://cocoon.apache.org/2.2/maven-plugins/])  
    36. 36: internal -> myfaces-archetype-helloworld (A simple archetype using MyFaces)  
    37. 37: internal -> myfaces-archetype-helloworld-facelets (A simple archetype usingMyFaces and facelets)  
    38. 38: internal -> myfaces-archetype-trinidad (A simple archetype using Myfaces and Trinidad)  
    39. 39: internal -> myfaces-archetype-jsfcomponents (A simple archetype for create custom JSF components using MyFaces)  
    40. 40: internal -> gmaven-archetype-basic (Groovy basic archetype)  
    41. 41: internal -> gmaven-archetype-mojo (Groovy mojo archetype)  

     

    当然,我们完全可以通过命令指定骨架,下面列出几常用的用法:

     

    创建普通Java项目:
    mvn archetype:create -DgroupId=[your project's group id] -DartifactId=[your project's artifact id]

    Xml代码  收藏代码
    1. mvn archetype:create -DgroupId=com.aboy -DartifactId=webmap  

     

    创建WEB项目:
    mvn archetype:create -DgroupId=[your project's group id] -DartifactId=[your project's artifact id] -DarchetypeArtifactId=maven-archetype-webapp

    Xml代码  收藏代码
    1. mvn archetype:create -DgroupId=com.aboy -DartifactId=webmap -DarchetypeArtifactId=maven-archetype-webapp  

     

    Maven其它命令简单说明:

    1、archetype( 内建插件,他的create任务将建立项目骨架 ): archetype:create

     

    2、groupId 项目的java包结构:com.aboy

     

    3、artifactId 项目的名称:webmap

     

    4、显示Maven默认设置  

    Xml代码  收藏代码
    1. mvn help:effective-pom  

     

    5、几个常用的archetypeArtifactId(项目骨架的类型):
    * maven-archetype-archetype 
    * maven-archetype-j2ee-simple 
    * maven-archetype-mojo 
    * maven-archetype-portlet 
    * maven-archetype-profiles
    * maven-archetype-quickstart 
    * maven-archetype-simple
    * maven-archetype-site 
    * maven-archetype-site-simple
    * maven-archetype-webapp

     

    6、生成清除Eclipse项目结构: 

    Xml代码  收藏代码
    1. mvn eclipse:eclipse  
    2. mvn eclipse:clean  

     

    7、清理(删除target目录下编译内容)

    Xml代码  收藏代码
    1. mvn clean  

     

    8、仅打包Web页面文件

    Xml代码  收藏代码
    1. mvn war:exploded  

     

    9、Maven的主要生命周期: 
    validate: 验证项目是否正确以及相关信息是否可用
    compile: 编译
    test: 通过junit进行单元测试
    package: 根据事先指定的格式(比如jar),进行打包
    integration-test: 部署到运行环境中,准备进行集成测试
    verify: 对包进行有效性性和质量检查
    install: 安装到本地代码库
    deploy: 在集成或发布环境,将包发布到远程代码库

     

  • 相关阅读:
    10. Regular Expression Matching
    9. Palindrome Number
    6. ZigZag Conversion
    5. Longest Palindromic Substring
    4. Median of Two Sorted Arrays
    3. Longest Substring Without Repeating Characters
    2. Add Two Numbers
    链式表的按序号查找
    可持久化线段树——区间更新hdu4348
    主席树——树链上第k大spoj COT
  • 原文地址:https://www.cnblogs.com/chenying99/p/2559200.html
Copyright © 2011-2022 走看看