快速创建maven 工程:simple java工程,webapp

http://www.cnblogs.com/buhaiqing/archive/2012/11/04/2754187.html

 

会从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 就可以达到你想要的目的了。

 

 

 

 

附上xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<archetype-catalog xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0 http://maven.apache.org/xsd/archetype-catalog-1.0.0.xsd"
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<archetypes>
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-quickstart</artifactId>
<version>1.0</version>
</archetype>
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-webapp</artifactId>
<version>1.0</version>
</archetype>
</archetypes>
</archetype-catalog>

posted @ 2015-12-21 11:45  IamThat  阅读(776)  评论(0编辑  收藏  举报