Maven Archetype

简介: 1. 从project创建archetype 在项目根目录下,运行  mvn archetype:create-from-project 创建的archetype工程在app_folder/target/generated-sources/archetype 目录下,其中archetype-resources包含用来创建原型项目的文件,META-INF/maven/arch

1. 从project创建archetype

在项目根目录下,运行 

mvn archetype:create-from-project  

创建的archetype工程在 app_folder/target/generated-sources/archetype 目录下,其中archetype-resources包含用来创建原型项目的文件,META-INF/maven/archetype-metadata.xml 是用来对文件结构进行详细描述的源文件。



2. Archetype的一些built-in参数

Variable Meaning
__rootArtifactId__ 做文件夹名替换用,例如__rootArtifactId__-dal
${rootArtifactId} Already explained above, it holds the value entered by the user as the project name (the value that maven ask as the artifactId: in the prompt when the user runs the archetype)
${artifactId} If your project is composed by one module, this variable will have the same value as ${rootArtifactId}, but if the project contains several modules, this variable will be replaced by the module name inside every module folder, for example: given a module named portlet-domain inside a project namedportlet, all the files inside this module folder that are to be filtered will have the value of the variable ${artifactId} replaced by portlet-domainwhereas the ${rootArtifactId} variable will be replaced by portlet
${package} The user provided package for the project, also prompted by maven when the user runs the archetype
${packageInPathFormat} The same value as ${package} variable but replacing '.' with the character'/', e.g:, for the package com.foo.bar this variable is com/foo/bar
${groupId} The user supplied groupId for the project, prompted by maven when the user runs the archetype
${version} The user supplied version for the project, prompted by maven when the user runs the archetype
 
The  archetype-metadata.xml  stored in the archetype-resources/META-INF/maven folder after the project is created, is where you need to tweak what you want generated and how.
  • id – This is the name of the module that will be generated.
  • dir – the template dir
  • name – the artifact Id that will be put in the pom file.


目录
相关文章
|
4月前
|
Dubbo Java 应用服务中间件
微服务框架(十)Maven Archetype制作Dubbo项目原型
  此系列文章将会描述Java框架Spring Boot、服务治理框架Dubbo、应用容器引擎Docker,及使用Spring Boot集成Dubbo、Mybatis等开源框架,其中穿插着Spring Boot中日志切面等技术的实现,然后通过gitlab-CI以持续集成为Docker镜像。   本文为Maven Archetype的制作及使用,使用archetype插件制作Dubbo项目原型
|
11月前
|
Java 数据库连接 Maven
IDEA下Maven骨架(archetype)搭建
通过Maven生成骨架(通用项目目录结构)流程记录
897 1
|
Java Maven Android开发
Eclipse使用Maven创建Web时错误:Could not resolve archetype
转载自:http://blog.csdn.net/afgasdg/article/details/12757433
299 0
Eclipse使用Maven创建Web时错误:Could not resolve archetype
|
前端开发 Java 数据库连接
【小白写工程】关于Maven的Archetype
【小白写工程】关于Maven的Archetype
109 0
|
开发框架 前端开发 Java
JAVA-带您弄清创建Maven项目-Archetype里那些看完茫然不解的骨架
JAVA-带您弄清创建Maven项目-Archetype里那些看完茫然不解的骨架
136 0
|
XML Java Apache
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart
146 0
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart
|
Java 中间件 测试技术
Maven Archetype 多 Module 自定义代码脚手架
大部分公司都会有一个通用的模板项目,帮助你快速创建一个项目。通常,这个项目需要集成一些公司内部的中间件、单元测试、标准的代码格式、通用的代码分层等等。
Maven Archetype 多 Module 自定义代码脚手架
|
Java Apache Maven
[Maven] 从mvn archetype:create命令说起
起因 在使用mvn archetype:create -DgroupId=com.test.demo -DartifactId=news-interface -DarchetypeArtifactId=maven-archetype-webapp在控制创建pom项目时,没有创建成功,错误信...
1215 0
|
域名解析 XML 存储
使用 Maven Archetype 创建 Java 项目模板
本文我们将为大家介绍maven的原型及其特性带来的好处,并且演示如何生成一个原型,以及利用原型来创建一个新项目。
1596 0
使用 Maven Archetype 创建 Java 项目模板