maven提供的腳手架archetype你們都知道啊,不知道的我這裏也很少說了,請自行參考Maven插件之maven-archetype-plugin。本文接下來是簡單介紹一下如何使用stdArcheType快速搭建快嘉開發框架1.0,參見快嘉開發框架1.0和示例介紹及使用說明。java
一、下載stdArcheType源碼,並install到本地倉庫;
二、新建本地目錄E:\tmp,cmd到該目錄下,git
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
備註
一、mvn archetype:generate -DinteractiveMode=false -DarchetypeGroupId=com.fas tjrun.share -DarchetypeArtifactId=stdArcheType -DarchetypeVersion=1.0 -Darchetyp eCatalog=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>