Maven的archetype Plugin可能大家都聽過,但不一定都能很好地用好它。缺省地如果你使用
mvn archetype:generate
會從maven的Repository里查找所有支持的arche types,大概有500~600個。正因為是太多了,所以查找起來很是不方便。
其實平時常用的arche type也就那么幾個。像我會用到的:
1.simple start
2. web app
3. Groovy basic
很自然的就會考慮,是不是能什么簡便的方法只需要從這3個組成的list里選擇就可以了。 答案當然是: Yes
實現步驟如下:(本機的Maven Repository目錄在C:\Users\buha\.m2 )
1. 使用mvn archetype:crawl 命令,它會在 C:\Users\buha\.m2\repository目錄下生成一個archetype-catalog.xml文件
2.將archetype-catalog.xml移到上一層目錄,也就是C:\Users\buha\.m2
3.這時再運行mvn archetype:generate -DarchetypeCatalog=local 就可以達到你想要的目的了。
是不是很方便啊。
想得到更全的archtetype-catalog.xml 可以訪問: http://repo1.maven.org/maven2/archetype-catalog.xml