1、生成archetype
从已有的工程生成archetype,无论多module的还是单module的,都一样。
在工程目录下(如果是多module的,就在父module目录下) 执行
mvn archetype:create-from-project
但是这样会把工程下所有文件都给打到archetype里去了,所以得加些配置,在目录建一个配置文件,
里面可以加入以下内容:
groupId The default groupId of the generated project. artifactId The default artifactId of the generated project. version The default version of the generated project. excludePatterns A comma-separated list of paths that will not be included in the resulting archetype. archetype.filteredExtensions File extensions which are checked for project's text files (vs binary files).
举个例子:
excludePatterns=.project,.classpath,.settings/**,target/**
以上配置可以把eclipse生成的一些目录给过滤掉,现在执行命令
mvn archetype:create-from-project archetype.properties=xx.properties
就会在当前目录的target下生成 generated-sources\archetype 这样一个目录,进入这个目录,在目录下执行
mvn install
archetype就会被打到本地maven仓库里去。之后也可以mvn deploy上传到远程仓库。
2、利用archetype生成工程
在想要生成工程的目录下执行
mvn archetype:generate DarchetypeCatalog=local
会列出来你本地仓库的所有archetype,可以选择你想要的,然后再根据提示依次输入groupId、artifactId、version、pacakge,就ok。如果不指定archetypeCatalog=local,会列出远程仓库的所有archetype,刷拉拉一大屏。。。
参考:http://maven.apache.org/archetype/maven-archetype-plugin/create-from-project-mojo.html
相关推荐
maven archetype-catalog.xml, 创建maven项目更快。
NULL 博文链接:https://huangmin001.iteye.com/blog/1184191
NULL 博文链接:https://huangmin001.iteye.com/blog/1185781
maven archetype-catalog.xml下载地址,需要的需要的可以下载看看!
MyEclipse 下maven 创建工程 catalog的问题、 无Archetype选择项问题、Filter为空 Maven archetype-catalog.xml
idea用maven骨架创建项目速度慢,添加archetype-catalog.xml到本地仓库的文件夹后,设置-DarchetypeCatalog=local,就能使用maven默认的archetype-catalog.xml,再不用远程下载。