使用Maven的archetype快速生成一個新項目

Maven的archetype Plugin可能你們都聽過,但不必定都能很好地用好它。缺省地若是你使用html

mvn archetype:generate web

會從maven的Repository裏查找全部支持的arche types,大概有500~600個。正由於是太多了,因此查找起來非常不方便。app

其實平時經常使用的arche type也就那麼幾個。像我會用到的:maven

1.simple start xml

2. web apphtm

3. Groovy basicget

很天然的就會考慮,是否是能什麼簡便的方法只須要從這3個組成的list裏選擇就能夠了。 答案固然是: Yesit

實現步驟以下:(本機的Maven Repository目錄在C:\Users\buha\.m2 )io

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 就能夠達到你想要的目的了。

 

是否是很方便啊。

Links:http://maven.40175.n5.nabble.com/archetype-catalog-xml-location-archetype-crawl-versus-archetype-generate-td113741.html 

想獲得更全的archtetype-catalog.xml 能夠訪問: http://repo1.maven.org/maven2/archetype-catalog.xml

相關文章
相關標籤/搜索