<build> <finalName>hhyz-archetype-web</finalName> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-archetype-plugin</artifactId> <version>2.2</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </pluginManagement> </build>
第四步: 从A-min项目中建立maven骨架项目git
打开CMD进入命令行,在项目根目录里执行: mvn archetype:create-from-project。web
成功执行完以后,在target/generated-sources/ 下有个archetype目录,这个就是生成的 archetype。能够看到这个目录其实就是普通的maven项目,也就是咱们最终的骨架模板项目,咱们称之为A-template项目。apache
有几个目录、文件须要说明:mybatis
第五步:改造A-templateeclipse
archetype:create-from-project并不是彻底智能,须要本身稍加修改maven
修改packing的值为jar或者war测试
<requiredProperties> <requiredProperty key="groupId"/> <requiredProperty key="artifactId"/> <requiredProperty key="version"> <defaultValue>1.0.0</defaultValue> </requiredProperty> </requiredProperties>
在fileSets同级下增长requiredProperties标签。requiredProperties定义模板项目中一些参数值,内置的参数包括:groupId,artifactId,version,package。本身能够提供这些参数的默认值,也能够增长本身额外的参数。大部分状况下,内置的参数足够用。fileSet标签有一个filtered=“true”属性,表示该fileSet可使用参数变量。在文件中引用参数变量的方式${参数名},例如${package}.一般生成A-template项目时,archetype插件会扫描A-min全部的文件,把须要替换为参数的地方自动替换。毕竟代码没有那么智能,有些地方会有问题。因此,咱们要检查每一个文件的参数部分是否是咱们预期的。增长参数、删除参数来达到咱们的要求。 ui
第六步:部署生成的archetype到本地仓库spa
cd进入generated-sourced/archetype目录,运行maven命令:mvn clean install,到这里咱们的模板骨架项目基本完成。插件
3.使用自定义的模板建立项目
方式一:使用命令行