maven提供的脚手架archetype大家都知道啊,不知道的我这里也不多说了,请自行参考Maven插件之maven-archetype-plugin。本文接下来是简单介绍一下如何使用stdArcheType快速搭建快嘉开发框架1.0,参见快嘉开发框架1.0和示例介绍及使用说明。
1、下载stdArcheType源码,并install到本地仓库;
2、新建本地目录E:\tmp,cmd到该目录下,
E:\tmp>mvn archetype:generate -DinteractiveMode=false -DarchetypeGroupId=com.fas
tjrun.share -DarchetypeArtifactId=stdArcheType -DarchetypeVersion=1.0 -Darchetyp
eCatalog=internal
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.4:generate (default-cli) > generate-sources
@ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.4:generate (default-cli) < generate-sources
@ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.4:generate (default-cli) @ standalone-pom --
-
[INFO] Generating project in Batch mode
[WARNING] Archetype not found in any catalog. Falling back to central repository
(http://repo.maven.apache.org/maven2).
[WARNING] Use -DarchetypeRepository=<your repository> if archetype's repository
is elsewhere.
[INFO] -------------------------------------------------------------------------
---
[INFO] Using following parameters for creating project from Archetype: stdArcheT
ype:1.0
[INFO] -------------------------------------------------------------------------
---
[INFO] Parameter: groupId, Value: com.fastjrun
[INFO] Parameter: artifactId, Value: demo
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: .
[INFO] Parameter: packageInPathFormat, Value: /
[INFO] Parameter: appName, Value: demo
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: .
[INFO] Parameter: groupId, Value: com.fastjrun
[INFO] Parameter: packagePrefix, Value: com.fastjrun.demo
[INFO] Parameter: artifactId, Value: demo
[INFO] Parent element not overwritten in E:\tmp\demo\Base\pom.xml
[WARNING] Don't override file E:\tmp\demo\Base\pom.xml
[INFO] Parent element not overwritten in E:\tmp\demo\Persistence-Impl\pom.xml
[WARNING] Don't override file E:\tmp\demo\Persistence-Impl\pom.xml
[INFO] Parent element not overwritten in E:\tmp\demo\RestController\pom.xml
[WARNING] Don't override file E:\tmp\demo\RestController\pom.xml
[INFO] Parent element not overwritten in E:\tmp\demo\Service-Impl\pom.xml
[WARNING] Don't override file E:\tmp\demo\Service-Impl\pom.xml
[INFO] Parent element not overwritten in E:\tmp\demo\Batch\pom.xml
[WARNING] Don't override file E:\tmp\demo\Batch\pom.xml
[INFO] Parent element not overwritten in E:\tmp\demo\Rest\Config\pom.xml
[WARNING] Don't override file E:\tmp\demo\Rest\Config\pom.xml
[INFO] Parent element not overwritten in E:\tmp\demo\Rest\Main\pom.xml
[WARNING] Don't override file E:\tmp\demo\Rest\Main\pom.xml
[INFO] Parent element not overwritten in E:\tmp\demo\RestTest\pom.xml
[WARNING] Don't override file E:\tmp\demo\RestTest\pom.xml
[INFO] project created from Archetype in dir: E:\tmp\demo
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.448 s
[INFO] Finished at: 2016-03-28T23:03:23+08:00
[INFO] Final Memory: 13M/310M
[INFO] ------------------------------------------------------------------------
E:\tmp>tree /F
文件夹 PATH 列表
卷序列号为 22AF-E645
E:.
└─demo
│ pom.xml
│
├─Base
│ │ pom.xml
│ │
│ └─src
│ └─main
│ └─java
├─Batch
│ │ pom.xml
│ │
│ ├─config
│ │ activemq.properties
│ │ batch.properties
│ │ jdbc.properties
│ │ log4j.dtd
│ │ log4j.xml
│ │ rabbitmq.properties
│ │ redis.properties
│ │ service.properties
│ │
│ └─src
│ └─main
│ ├─bin
│ │ shutdown.sh
│ │ startup.bat
│ │ startup.sh
│ │
│ ├─config
│ │ activemq.properties
│ │ batch.properties
│ │ jdbc.properties
│ │ log4j.dtd
│ │ log4j.xml
│ │ rabbitmq.properties
│ │ redis.properties
│ │ service.properties
│ │
│ ├─java
│ └─resources
│ applicationContext-activemq-consumer.xml
│ applicationContext-batch-invalidLoginCredentialTask.xml
│ applicationContext-batch-unLockUserPwdTask.xml
│ applicationContext-batch.xml
│ applicationContext-rabbitmq-consumer.xml
│ applicationContext.xml
│ log4j.properties
│ package.xml
│
├─Persistence-Impl
│ │ pom.xml
│ │
│ └─src
│ ├─main
│ │ ├─java
│ │ └─resources
│ │ applicationContext-persistence.xml
│ │ jdbc.properties
│ │ log4j.properties
│ │
│ └─test
│ ├─java
│ └─resources
│ applicationContext.xml
│ testng.xml
│
├─Rest
│ ├─Config
│ │ │ pom.xml
│ │ │
│ │ └─src
│ │ └─main
│ │ └─resources
│ │ activemq.properties
│ │ jdbc.properties
│ │ log4j.dtd
│ │ log4j.xml
│ │ package.xml
│ │ rabbitmq.properties
│ │ redis.properties
│ │ service.properties
│ │
│ └─Main
│ │ pom.xml
│ │
│ └─src
│ └─main
│ ├─java
│ ├─resources
│ │ applicationContext.xml
│ │ codeMsg.properties
│ │ log4j.properties
│ │
│ └─webapp
│ └─WEB-INF
│ spring-mvc.xml
│ web.xml
│
├─RestController
│ │ pom.xml
│ │
│ └─src
│ ├─main
│ │ └─java
│ └─test
│ ├─java
│ └─resources
├─RestTest
│ │ pom.xml
│ │
│ └─src
│ └─main
│ ├─java
│ ├─resources
│ │ log4j.properties
│ │ package.xml
│ │ service.properties
│ │ testng.xml
│ │
│ └─testdata
│ local.properties
│
└─Service-Impl
│ pom.xml
│
└─src
├─main
│ ├─java
│ └─resources
│ activemq.properties
│ applicationContext-activemq-producer.xml
│ applicationContext-jedis.xml
│ applicationContext-rabbitmq-producer.xml
│ applicationContext-service.xml
│ jdbc.properties
│ log4j.properties
│ rabbitmq.properties
│ redis.properties
│ service.properties
│
└─test
├─java
└─resources
applicationContext.xml
testng.xml
备注
1、mvn archetype:generate -DinteractiveMode=false -DarchetypeGroupId=com.fas tjrun.share -DarchetypeArtifactId=stdArcheType -DarchetypeVersion=1.0 -Darchetyp eCatalog=internal命令中加入-DarchetypeCatalog=internal是为了生成脚手架快一些,否则会需要从远程服务器上下载很多archetype,导致生成慢;
2、该插件有几个参数,注意如下
<requiredProperties>
<requiredProperty key="appName">
<defaultValue>demo</defaultValue>
</requiredProperty>
<requiredProperty key="groupId">
<defaultValue>com.fastjrun</defaultValue>
</requiredProperty>
<requiredProperty key="artifactId">
<defaultValue>demo</defaultValue>
</requiredProperty>
<requiredProperty key="package">
<defaultValue>.</defaultValue>
</requiredProperty>
<requiredProperty key="packagePrefix">
<defaultValue>com.fastjrun.demo</defaultValue>
</requiredProperty>
</requiredProperties>