maven archetype:generate 的进一步理解

本文参考和转自:http://cloudera.iteye.com/blog/770505和http://jiajun.iteye.com/blog/465496

可以说纠结了不少时间了

用mvn archetyoe:generate 时总是会出现以下的情况:

 

正常的应该是

 

Java代码   收藏代码
  1. $ mvn archetype:generate  
  2. [INFO] Scanning for projects...  
  3. [INFO] Searching repository for plugin with prefix: 'archetype'.  
  4. [INFO] ------------------------------------------------------------------------  
  5. [INFO] Building Maven Default Project  
  6. [INFO]    task-segment: [archetype:create] (aggregator-style)  
  7. [INFO] ------------------------------------------------------------------------  
  8. [INFO] Preparing archetype:generate  
  9. [INFO] No goals needed for project - skipping  
  10. [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.  
  11. [INFO] Setting property: velocimacro.messages.on => 'false'.  
  12. [INFO] Setting property: resource.loader => 'classpath'.  
  13. [INFO] Setting property: resource.manager.logwhenfound => 'false'.  
  14. [INFO] [archetype:generate]  
  15. Choose archetype:  
  16. 1: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web application with Hibernate, Spring and JSF)  
  17. 2: internal -> appfuse-basic-spring (AppFuse archetype for creating a web application with Hibernate, Spring and Spring MVC)  
  18. ...........  
  19. internal -> maven-archetype-sar (JBoss Service Archive)  
  20. 36: internal -> wicket-archetype-quickstart (A simple Apache Wicket project)  
  21. Choose a number:  (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36): 15  
  22. ....  

 

 

以前使用一直正常(有一段时间了)

可现在无论在哪台机器上都是这样的情况:

Java代码   收藏代码
  1. [INFO] Scanning for projects...  
  2. [INFO] Searching repository for plugin with prefix: 'archetype'.  
  3. [INFO] ------------------------------------------------------------------------  
  4. [INFO] Building Maven Default Project  
  5. [INFO]    task-segment: [archetype:generate] (aggregator-style)  
  6. [INFO] ------------------------------------------------------------------------  
  7. [INFO] Preparing archetype:generate  
  8. [INFO] No goals needed for project - skipping  
  9. [INFO] [archetype:generate {execution: default-cli}]  
  10. [INFO] Generating project in Interactive mode  
  11. [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)  
  12. Choose archetype:  
  13. 1: remote -> docbkx-quickstart-archetype (null)  
  14. 2: remote -> gquery-archetype (null)  
  15. .......  
  16. 288: remote -> trails-secure-archetype (null)  
  17. 289: remote -> tynamo-archetype (null)  
  18. 290: remote -> wicket-scala-archetype (Basic setup for a project that combines Scala and Wicket,  
  19.                 depending on the Wicket-Scala project. Includes an example Specs  
  20.                 test.)  
  21. 291: remote -> circumflex-archetype (null)  
  22. Choose a number: 80:  
  23. ....  

  

居然是这样,到了290了....

而且choose a nubmer 默认写了个80不知道啥意思..... 选以前的web项目(18) 不管用还是继续让我choose version

最后发现可以choose的version 只有 1 和2 ..

根本没有普通java项目和web项目

咋回事儿?

 

 

 

 

 后来找到了解决方案:

方案1:绕行

mvn archetype:create -DgroupId=[your group id] -DartifactId=[your archetype id] -DarchetypeArtifactId=maven-archetype-webapp

  

方案2 : 谢谢,juvenshun 大哥的帮助。(引用):

Java代码   收藏代码
  1. 可以使用 $mvn archetype:generate -DarchetypeCatalog=internal  
  2. archetypeCatalog表示插件使用的archetype元数据,默认值为remote,local,即中央仓库archetype元数据(http://repo1.maven.org/maven2/archetype-catalog.xml)加上插件内置元数据的和  
  3. 由于中央仓库的archetype太多,导致这个列表太长  
  4. 因此自己指定仅用内置元数据(20个左右,好像),就可以解决你的烦恼了  

对于maven中archetypeArtifactId的类型的选择:

是否一开始就这么做?

Script代码   收藏代码
  1. mvn archetype:create -DgroupId=org.cjj.site -DartifactId=org.cjj.site -DpackageName=org.cjj.site -DarchetypeArtifactId=maven-archetype-webapp  

重要的

Script代码   收藏代码
  1. archetypeArtifactId  

不是吗?

 

但是,当我们创建spring项目或者struts项目,到哪里去查他们的archetypeArtifactId呢?

我google了一下,发现一个好资源:http://cwiki.apache.org/confluence/display/WW/Struts+2+Maven+Archetypes

 

呵呵,今天发现原来可以这样:

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

 接下来的事情,很舒服,选择一个类别吧.

Java代码   收藏代码
  1. E:\workspace>mvn archetype:generate  
  2. [INFO] Scanning for projects...  
  3. [INFO] Searching repository for plugin with prefix: 'archetype'.  
  4. [INFO] ------------------------------------------------------------------------  
  5. [INFO] Building Maven Default Project  
  6. [INFO]    task-segment: [archetype:generate] (aggregator-style)  
  7. [INFO] ------------------------------------------------------------------------  
  8. [INFO] Preparing archetype:generate  
  9. [INFO] No goals needed for project - skipping  
  10. [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.  
  11. [INFO] Setting property: velocimacro.messages.on => 'false'.  
  12. [INFO] Setting property: resource.loader => 'classpath'.  
  13. [INFO] Setting property: resource.manager.logwhenfound => 'false'.  
  14. [INFO] [archetype:generate {execution: default-cli}]  
  15. [INFO] Generating project in Interactive mode  
  16. [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)  
  17. Choose archetype:  
  18. 1: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web application with Hibernate, Spring and JSF)  
  19. 2: internal -> appfuse-basic-spring (AppFuse archetype for creating a web application with Hibernate, Spring and Spring MVC)  
  20. 3: internal -> appfuse-basic-struts (AppFuse archetype for creating a web application with Hibernate, Spring and Struts 2)  
  21. 4: internal -> appfuse-basic-tapestry (AppFuse archetype for creating a web application with Hibernate, Spring and Tapestry 4)  
  22. 5: internal -> appfuse-core (AppFuse archetype for creating a jar application with Hibernate and Spring and XFire)  
  23. 6: internal -> appfuse-modular-jsf (AppFuse archetype for creating a modular application with Hibernate, Spring and JSF)  
  24. 7: internal -> appfuse-modular-spring (AppFuse archetype for creating a modular application with Hibernate, Spring and Spring MVC)  
  25. 8: internal -> appfuse-modular-struts (AppFuse archetype for creating a modular application with Hibernate, Spring and Struts 2)  
  26. 9: internal -> appfuse-modular-tapestry (AppFuse archetype for creating a modular application with Hibernate, Spring and Tapestry 4)  
  27. 10: internal -> maven-archetype-j2ee-simple (A simple J2EE Java application)  
  28. 11: internal -> maven-archetype-marmalade-mojo (A Maven plugin development project using marmalade)  
  29. 12: internal -> maven-archetype-mojo (A Maven Java plugin development project)  
  30. 13: internal -> maven-archetype-portlet (A simple portlet application)  
  31. 14: internal -> maven-archetype-profiles ()  
  32. 15: internal -> maven-archetype-quickstart ()  
  33. 16: internal -> maven-archetype-site-simple (A simple site generation project)  
  34. 17: internal -> maven-archetype-site (A more complex site project)  
  35. 18: internal -> maven-archetype-webapp (A simple Java web application)  
  36. 19: internal -> jini-service-archetype (Archetype for Jini service project creation)  
  37. 20: internal -> softeu-archetype-seam (JSF+Facelets+Seam Archetype)  
  38. 21: internal -> softeu-archetype-seam-simple (JSF+Facelets+Seam (no persistence) Archetype)  
  39. 22: internal -> softeu-archetype-jsf (JSF+Facelets Archetype)  
  40. 23: internal -> jpa-maven-archetype (JPA application)  
  41. 24: internal -> spring-osgi-bundle-archetype (Spring-OSGi archetype)  
  42. 25: internal -> confluence-plugin-archetype (Atlassian Confluence plugin archetype)  
  43. 26: internal -> jira-plugin-archetype (Atlassian JIRA plugin archetype)  
  44. 27: internal -> maven-archetype-har (Hibernate Archive)  
  45. 28: internal -> maven-archetype-sar (JBoss Service Archive)  
  46. 29: internal -> wicket-archetype-quickstart (A simple Apache Wicket project)  
  47. 30: internal -> scala-archetype-simple (A simple scala project)  
  48. 31: internal -> lift-archetype-blank (A blank/empty liftweb project)  
  49. 32: internal -> lift-archetype-basic (The basic (liftweb) project)  
  50. 33: internal -> cocoon-22-archetype-block-plain ([http://cocoon.apache.org/2.2/maven-plugins/])  
  51. 34: internal -> cocoon-22-archetype-block ([http://cocoon.apache.org/2.2/maven-plugins/])  
  52. 35: internal -> cocoon-22-archetype-webapp ([http://cocoon.apache.org/2.2/maven-plugins/])  
  53. 36: internal -> myfaces-archetype-helloworld (A simple archetype using MyFaces)  
  54. 37: internal -> myfaces-archetype-helloworld-facelets (A simple archetype using MyFaces and facelets)  
  55. 38: internal -> myfaces-archetype-trinidad (A simple archetype using Myfaces and Trinidad)  
  56. 39: internal -> myfaces-archetype-jsfcomponents (A simple archetype for create custom JSF components using MyFaces)  
  57. 40: internal -> gmaven-archetype-basic (Groovy basic archetype)  
  58. 41: internal -> gmaven-archetype-mojo (Groovy mojo archetype)  
  59. Choose a number:  (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36/37/38/39/40/4115: :  

 选择41个类型,有你所要的吗?选择一个数字即可.

下面就剩下你根据提示来填空了.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值