maven提供的腳手架archetype你們都知道啊,不知道的我這裏也很少說了,請自行參考Maven插件之maven-archetype-plugin。本文接下來是簡單介紹一下如何使用stdArcheType快速搭建快嘉開發框架1.1,參見快嘉開發框架1.1和示例介紹及使用說明。java
一、下載stdArcheType源碼,選擇分支release1.1,並install到本地倉庫;
二、新建本地目錄E:\tmp,cmd到該目錄下,git
E:\tmp>mvn archetype:generate -DinteractiveMode=false -DarchetypeGroupId=com.fastjrun.share -DarchetypeArtifactId=stdArcheType -DarchetypeVersion=1.1 -DarchetypeCatalog=internal [INFO] Scanning for projects... Downloading: http://javafun.cuiyingfeng.com/nexus/content/groups/public/org/code haus/mojo/maven-metadata.xml Downloading: http://javafun.cuiyingfeng.com/nexus/content/groups/public/org/mule /tools/maven-metadata.xml Downloading: http://javafun.cuiyingfeng.com/nexus/content/groups/public/org/apac he/maven/plugins/maven-metadata.xml Downloaded: http://javafun.cuiyingfeng.com/nexus/content/groups/public/org/mule/ tools/maven-metadata.xml (2 KB at 1.9 KB/sec) Downloaded: http://javafun.cuiyingfeng.com/nexus/content/groups/public/org/codeh aus/mojo/maven-metadata.xml (20 KB at 34.6 KB/sec) Downloaded: http://javafun.cuiyingfeng.com/nexus/content/groups/public/org/apach e/maven/plugins/maven-metadata.xml (13 KB at 21.7 KB/sec) Downloading: http://javafun.cuiyingfeng.com/nexus/content/groups/public/org/apac he/maven/plugins/maven-archetype-plugin/maven-metadata.xml Downloaded: http://javafun.cuiyingfeng.com/nexus/content/groups/public/org/apach e/maven/plugins/maven-archetype-plugin/maven-metadata.xml (759 B at 12.2 KB/sec) [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.1 [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\Common\pom.xml [WARNING] Don't override file E:\tmp\demo\Common\pom.xml [INFO] Parent element not overwritten in E:\tmp\demo\Util\pom.xml [WARNING] Don't override file E:\tmp\demo\Util\pom.xml [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\Bundle\pom.xml [WARNING] Don't override file E:\tmp\demo\Bundle\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] Parent element not overwritten in E:\tmp\demo\Web\Config\pom.xml [WARNING] Don't override file E:\tmp\demo\Web\Config\pom.xml [INFO] Parent element not overwritten in E:\tmp\demo\Web\Main\pom.xml [WARNING] Don't override file E:\tmp\demo\Web\Main\pom.xml [INFO] project created from Archetype in dir: E:\tmp\demo [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.533 s [INFO] Finished at: 2016-08-22T22:45:54+08:00 [INFO] Final Memory: 12M/78M [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 │ ├─Bundle │ │ pom.xml │ │ │ └─src │ ├─main │ │ └─java │ └─test │ ├─java │ └─resources ├─Common │ │ pom.xml │ │ │ └─src │ └─main │ └─java ├─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 │ ├─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 │ ├─Util │ │ pom.xml │ │ │ └─src │ └─main │ ├─java │ └─resources └─Web ├─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 │ freemarker.properties │ log4j.properties │ └─webapp └─WEB-INF │ spring-mvc.xml │ web.xml │ └─ftl
備註
一、mvn archetype:generate -DinteractiveMode=false -DarchetypeGroupId=com.fastjrun.share -DarchetypeArtifactId=stdArcheType -DarchetypeVersion=1.1 -DarchetypeCatalog=internal命令中加入-DarchetypeCatalog=internal是爲了生成腳手架快一些,不然會須要從遠程服務器上下載不少archetype,致使生成慢;
二、該插件有幾個參數,注意以下web
<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>