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. splunk dga

    https://splunkbase.splunk.com/app/3559/ 详细参考: https://www.slideshare.net/Splunk/using-machine-learni ...

  2. appuploader 使用

    mac 使用 Jar Lanucher.app 打开 解压后的 appuploader.jar 文件,即可启动 appuploader. 内容 网址 官方网站 http://www.appupload ...

  3. continue语句:编程把100-300之间的能被25整除的数输出

    #include<stdio.h>void main(){ int n; for(n=100;n<=300;n++) { if(n%25!=0) continue; printf(& ...

  4. RabbitMQ六种队列模式-发布订阅模式

    前言 RabbitMQ六种队列模式-简单队列RabbitMQ六种队列模式-工作队列RabbitMQ六种队列模式-发布订阅 [本文]RabbitMQ六种队列模式-路由模式RabbitMQ六种队列模式-主 ...

  5. 【转】Fiddler常见用法

    转载自:https://blog.csdn.net/china_jeffery/article/details/82426586 一.会话过滤器 选中[Filters]–> [Use Filte ...

  6. UFUN函数 UF_ASSEM UF_PART函数(UF_ASSEM_ask_work_part,UF_PART_ask_part_name)

    UF_initialize(); tag_t work_part_tag=NULL_TAG; ]=""; //获取当前工作部件的tag work_part_tag=UF_ASSEM ...

  7. 苹果MAC OS查看MAC地址及修改ip

    一,查看mac地址 第一步: 第二步: 第三步: 二,更改IP 第一步: 第二步: 第三步: 最后点击“好”就完成了 我要这天再遮不住我眼,要这地再埋不了我心.要这天下众生都明白我意,要那诸佛都烟消云 ...

  8. P1501 [国家集训队]Tree II LCT

    链接 luogu 思路 简单题 代码 #include <bits/stdc++.h> #define ls c[x][0] #define rs c[x][1] using namesp ...

  9. 各软件发布版本简写(Alpha Beta RC GA DMR)

    Alpha:是内部测试版,一般不向外部发布,会有很多Bug.一般只有测试人员使用. Beta:也是测试版,这个阶段的版本会一直加入新的功能.在Alpha版之后推出. RC:(Release Candi ...

  10. js处理事件冒泡(兼容写法)

    event = event || window.event; if (event.stopPropagation) { event.stopPropagation(); } else { event. ...