Maven Archetype
创建并使用
1.基于现有结构来生成骨架,比如你写了个骨架项目基于骨架项目快速生成Archetype模版供大家使用
mvn archetype:create-from-project -s /Users/liqiang/Desktop/environment/apache-maven-3.9.6/conf/settings.xml
2.cd到生成的模版
cd target/generated-sources/archetype
3.安装Archetype
mvn install
4.使用Maven Archetype生成项目
mvn archetype:generate -DarchetypeCatalog=local
#local表示使用本地的archetype maven有内置的和我们安装的 不从远程查找
5.禁用交互式模式 比如使用脚本生成不采用交互式询问输入
mvn archetype:generate \ -DarchetypeGroupId=org.example \ -DarchetypeArtifactId=data-fusion-sdk-archetype \ -DarchetypeVersion=1.0-SNAPSHOT \ -DgroupId=com.example \ -DartifactId=my-project \ -Dversion=1.0.0 \ -Dpackage=com.example.myproject \ -DarchetypeCatalog=local \ -DinteractiveMode=false
参数说明
-DinteractiveMode=false
参数告诉 Maven Archetype 插件禁用交互模式,因此不会询问你是否确认。
Archetype的坐标
-DarchetypeGroupId=org.example \
-DarchetypeArtifactId=data-fusion-sdk-archetype \
-DarchetypeVersion=1.0-SNAPSHOT \
常见问题
生成骨架卡的问题
Generating project in Batch mode
1.使用本地-DarchetypeCatalog=local
install的时候会在本地生成
推到私服后如何使用
使用远程nexus仓库的archetype创建项目的时候,必须在自己的maven conf 下settings.xml加入以下配置:
因为Maven 3改变了原型存储库的集成方式。该-DarchetypeRepository
参数不再存在。相反,需要将archteype存储库添加到settings.xml 并在命令指定settings.xml 如果全局改了就不用指定
mvn archetype:generate -DarchetypeGroupId=org.example -DarchetypeArtifactId=data-fusion-sdk-archetype -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=com.example -DartifactId=my-project -Dversion=1.0.0 -Dpackage=com.example.myproject -DinteractiveMode=false -s D:\yxtgit.hxyxt.com\settings.xml
<profile> <!-- the profile id is arbitrary 这个id是任意填的--> <id>my_archetype</id> <repositories> <repository> <!-- the repository id has to be named: archetype 这repository Id必须是archetype --> <id>archetype</id> <name>my archetypes</name> <url>http://127.0.0.1:8081/repository/maven-public/</url> <releases> <enabled>true</enabled> <checksumPolicy>fail</checksumPolicy> </releases> <snapshots> <enabled>true</enabled> <checksumPolicy>warn</checksumPolicy> </snapshots> </repository> </repositories> </profile> <activeProfiles> <activeProfile>my_archetype</activeProfile> <!-- 这个id是上面的profile id -->
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
2021-05-14 linux-用户管理