我是靠谱客的博主 无奈鞋子,这篇文章主要介绍maven+idea构建自己的archetype前言1、建立一个模板项目2、根据模板项目生成archetype3、将archetype安装到仓库4、idea中加入指定archetype5、根据自己建立的archetype新建项目总结,现在分享给大家,希望可以做个参考。
前言
1、建立一个模板项目
按照如下目录生成
2、根据模板项目生成archetype
进入到项目根目录下
在控制台窗口中执行如下命令
mvn archetype:create-from-project
出现如下提示,表示生成archetype成功
这个时候也会在这个目录下多处一个target目录,其中就有archetype的相关信息
3、将archetype安装到仓库
这一步我这里只安装到本地,如果安装到自动的私服,需要有相关插件支持,这里不做总结
之后进入到target中的archetype下
cd target/generated-sources/archetype/
执行install命令,安装到本地maven仓库
mvn install
这个会将该archetype的信息加入到本地仓库的archetype-catalog.xml文件中
mvn archetype:crawl
4、idea中加入指定archetype
最好以archetype-catalog.xml文件中的相关信息为准
贴一个生成的archetype-catalog.xml文件,其中的第一个archetype就是我们本地生成的archetype
<?xml version="1.0" encoding="UTF-8"?>
<archetype-catalog xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0 http://maven.apache.org/xsd/archetype-catalog-1.0.0.xsd"
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<archetypes>
<archetype>
<groupId>com.learn</groupId>
<artifactId>common-learn-archetype</artifactId>
<version>1.0-SNAPSHOT</version>
<description>common-learn-archetype</description>
</archetype>
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-quickstart</artifactId>
<version>1.0</version>
<description>quickstart</description>
</archetype>
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-quickstart</artifactId>
<version>1.4</version>
<description>quickstart</description>
</archetype>
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-webapp</artifactId>
<version>1.3</version>
<description>webapp</description>
</archetype>
</archetypes>
</archetype-catalog>
在idea中输入如下信息即可
5、根据自己建立的archetype新建项目
在建立项目的时候,选中指定的archetype即可。
输入相关项目的groupId和artifcatId之后,建立的项目结构如下所示,与archetype一致。
总结
一个maven中archetype简单使用的总结
最后
以上就是无奈鞋子最近收集整理的关于maven+idea构建自己的archetype前言1、建立一个模板项目2、根据模板项目生成archetype3、将archetype安装到仓库4、idea中加入指定archetype5、根据自己建立的archetype新建项目总结的全部内容,更多相关maven+idea构建自己内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复