进公司工作工作发现每个公司都有自己的脚手架来初始化项目,故也想开发一套自己的脚手架进行使用,会整合一些常用的东西,来解放双手
org.apache.maven.plugins
maven-archetype-plugin
3.2.1
org.apache.maven.plugins
maven-compiler-plugin
3.8.1
mvn archetype:create-from-project
mvn clean install```
6. 查看本地maven仓库地址,会有一个archetype-catalog.xml文件后打开后会有构建信息如:
com.yh.zq
project-name
1.0.0
desc
7. 至此就创建成功了自定义的Archetype,可以通过命令从本地模板创建工程
mvn archetype:generate -DarchetypeCatalog=local
8. 上传Archetype到私服
Archetype目录下的pom文件粘贴私服地址
releases
Nexus Release Repository
xxxxx
snapshots
Nexus Snapshot Repository
xxxx
```
执行maven部署命令
mvn deploy
mvn archetype:generate -DarchetypeCatalog=local
mvn archetype:generate -DinteractiveMode=false -DgroupId=com.yh.zq -DartifactId=yh-demo-test -Dversion=1.0-SNAPSHOT -Dpackage=com.zq.yh -DarchetypeGroupId=yhlovezq.top -DarchetypeArtifactId=yh-archetype -DarchetypeVersion=1.0-SNAPSHOT -DarchetypeRepository=http://n.qdedu.cn/nexus/content/repositories/snapshots/
mvn archetype:generate -DgroupId=com.free -DartifactId=demo-t -Dversion=1.0.0 -Dpackage=com.free.demo -DarchetypeGroupId=yhlovezq.top -DarchetypeArtifactId=yh-archetype -DarchetypeVersion=1.0-SNAPSHOT -DinteractiveMode=false
参数说明:
命令参数 介绍
DgroupId 所需生成项目的groupId
DartifactId 所需生成项目的artifactId
Dversion 所需生成项目的version
Dpackage 所需生成项目的包名
DarchetypeGroupId Archetypal模板的groupId
DarchetypeArtifactId Archetypal模板的artifactId
DarchetypeVersion Archetypal模板的version
DarchetypeRepository 私服地址
12. 其他人通过maven命令使用该脚手架时候要么setting文件进行配置要么指定私服地址进行使用
通过idea进行添加的方式不作赘述。