idea自定义maven骨架
创建maven项目
首先创建一个简单的maven-archetype-quickstart
(可以是其他骨架类型)项目,这里我们叫vspro-skeleton
然后在pluginManagement
的节点中加入:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>3.1.2</version>
</plugin>
</plugins>
</pluginManagement>
执行命令
接下来依次执行三个命令:
- archetype:create-from-project
- install
- archetype:crawl
执行archetype:create-from-project
命令:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传
执行install
,注意,执行的目录一定是archetype:create-from-project
命令执行后生成的target目录下的archetype下:
执行archetype:crawl
命令:
生成的maven-metadata-local.xml
文件就在这个maven本地仓库下的这个包名下,这里是E:\installed\repo\com\github\vspro\vspro-skeleton\maven-metadata-local.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.github.vspro</groupId>
<artifactId>vspro-skeleton</artifactId>
<versioning>
<versions>
<version>1.0-SNAPSHOT</version>
</versions>
<lastUpdated>20191027140237</lastUpdated>
</versioning>
</metadata>
在idea中添加自定义的archetype:
这样就加进去了:
下次创建项目的时候,就可以直接选择自定义的骨架了,之后的流程都一样