1.  准备好一个编辑好的模板工程

2. 在 pom.xml 中添加 maven-archetype-plugin 插件

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>2.4</version>
</plugin>

3. 执行: mvn archetype:create-from-project,生成对应的 archetype 工程
(IDEA 可以直接在 Maven Projects 面板上点击)

4. 导入刚刚生成的 archetype 工程
在 target\generated-sources\archetype 目录下有个 pom.xml,IDEA 可以直接拖放到 Maven Projects 面板上,就可以导入了

5. 编辑 target\generated-sources\archetype\src\main\resources\META-INF\maven\archetype-metadata.xml,设置模板工程需要使用到的文件,删除不必要配置(比如:pom 中 maven-archetype-plugin 的配置)。

我这里设置成如下:
(为了避免每次生成 archetype 工程都重新编辑 archetype-metadata.xml,可以将修改好的 archetype-metadata.xml 放在模板工程里面)

<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="template-sf-boot"
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fileSets>
<fileSet filtered="true" packaged="true" encoding="UTF-8">
<directory>src/main/java</directory>
<includes>
<include>**/**</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory>src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory>src/main/assembly</directory>
<includes>
<include>**/**</include>
</includes>
</fileSet>
</fileSets>
</archetype-descriptor>

filtered="true" 表示这些文件需要替换里面的占位符: ${}

6. mvn install 这个 archetype(注意:是 archetype 工程)

7. 通过 archetype 生成工程
有三种方式:
a. maven 命令
mvn archetype:generate -DarchetypeRepository=local -DarchetypeGroupId=com.xx.xx -DarchetypeArtifactId=template-xxx-archetype -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=com.kvn.demo -DartifactId=demo-test
(关闭对话模式,添加参数:-DinteractiveMode=false )

b. IDEA 或者 eclipse

参考: https://www.cnblogs.com/fengpingfan/p/5179735.html
https://github.com/alonWang/maven-custom-archetype

maven-archetype-plugin 的正确打开方式的更多相关文章

  1. iOS开发小技巧--相机相册的正确打开方式

    iOS相机相册的正确打开方式- UIImagePickerController 通过指定sourceType来实现打开相册还是相机 UIImagePickerControllerSourceTypeP ...

  2. Xcode 的正确打开方式——Debugging(转载)

    Xcode 的正确打开方式——Debugging   程序员日常开发中有大量时间都会花费在 debug 上,从事 iOS 开发不可避免地需要使用 Xcode.这篇博客就主要介绍了 Xcode 中几种能 ...

  3. C#语法——泛型的多种应用 C#语法——await与async的正确打开方式 C#线程安全使用(五) C#语法——元组类型 好好耕耘 redis和memcached的区别

    C#语法——泛型的多种应用   本篇文章主要介绍泛型的应用. 泛型是.NET Framework 2.0 版类库就已经提供的语法,主要用于提高代码的可重用性.类型安全性和效率. 泛型的定义 下面定义了 ...

  4. InnoDB缓冲池预加载在MySQL 5.7中的正确打开方式

    InnoDB缓冲池预加载在MySQL 5.7中的正确打开方式 https://mp.weixin.qq.com/s/HGa_90XvC22anabiBF8AbQ 在这篇文章里,我将讨论在MySQL 5 ...

  5. Console控制台的正确打开方式

    Console控制台的正确打开方式 console对象提供了访问浏览器调试模式的信息到控制台 -- Console对象 |-- assert() 如果第一个参数断言为false,则在控制台输出错误信息 ...

  6. 任务队列和异步接口的正确打开方式(.NET Core版本)

    任务队列和异步接口的正确打开方式 什么是异步接口? Asynchronous Operations Certain types of operations might require processi ...

  7. (一)Redis for Windows正确打开方式

    目录 (一)Redis for Windows正确打开方式 (二)Redis for 阿里云公网连接 (三)Redis for StackExchange.Redis 下载地址 官网.中文网1 及 中 ...

  8. List的remove()方法的三种正确打开方式

    转: java编程:List的remove()方法的三种正确打开方式! 2018年08月12日 16:26:13 Aries9986 阅读数 2728更多 分类专栏: leetcode刷题   版权声 ...

  9. C++11随机数的正确打开方式

    C++11随机数的正确打开方式 在C++11之前,现有的随机数函数都存在一个问题:在利用循环多次获取随机数时,如果程序运行过快或者使用了多线程等方法,srand((unsigned)time(null ...

  10. Pull Request的正确打开方式(如何在GitHub上贡献开源项目)

    Pull Request的正确打开方式(如何在GitHub上贡献开源项目) GitHub的官方帮助如下: Fork A Repo: https://help.github.com/articles/f ...

随机推荐

  1. poj1502 MPI Maelstrom(单源最短路)

    题意:表面乍一看output是输出最小值,但仔细研究可以发现,这个最小值是从点1到所有点所花时间的最小值,其实是访问这些节点中的最大值,因为只有访问了最长时间的那个点才算访问了所有点.所以求最短路之后 ...

  2. 某个新闻网站抓去自媒体账号 queryId js破解

    第一步: 发现加密 第二部:搜索加密参数 queryId 第三部:找到js核心加密代码 第四部:代码实现 window = {} function utf8ToBase64(t) { console. ...

  3. 201671010446姚良实验十四团队项目评审&课程总结

    实验十四 团队项目评审&课程学习总结 项目 内容 这个作业属于哪个课程 http://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cn ...

  4. python应用-输出验证码

    from random import randint def generate_code (code_len): """ 生成确定位数的验证码 :param code_l ...

  5. Java 多线程学习扩展

    http://www.imooc.com/video/5176 一.如何扩展Java并发知识 Java Memory Mode JMM描述了Java线程如何通过内存进行交互 happens-befor ...

  6. luoguP1742 最小圆覆盖

    最小圆覆盖 首先 没错,我是个蒟蒻.luogu 流程 圆 C; for(i=1 to n) { if(P[i] 不在 C 内) { C = {P[i], 0}; for(j=1 to i-1) { i ...

  7. 洛谷 P2815 IPv6地址压缩 题解

    P2815 IPv6地址压缩 题目背景 (友情提示:IPv6基础知识曾多次出现在NOIP初赛中)Internet Protocol,互联网协议,即为我们常说的IP.我们目前常说的IP主要指它的第四版, ...

  8. 使用charles对jmeter进行抓包

  9. SpringSecurity匿名用户访问权限

    在SpringSecurity中定义一个匿名访问权限,实现未登录用户可以访问默写页面 <http use-expressions="false" entry-point-re ...

  10. UDF——Fluent与Matlab数据耦合

    本文编译工具:VC++ UDF Studio 该插件可以直接在Visual Studio中一键编译.加载.调试UDF源码,极大提高编写排错效率,且支持C++,MFC,Windows API和第三方库, ...