您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)如何使用Maven Archetype插件構(gòu)建Maven工程原型模板的示例分析,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
創(chuàng)建原型模板
1、在空目錄運(yùn)行archetype:generate上面的命令,待下載完必要的jar包后,首先需要輸入內(nèi)置的原型編號(hào);
Choose archetype: 1: internal -> org.apache.maven.archetypes:maven-archetype-archetype (An archetype which contains a sample archetype.) 2: internal -> org.apache.maven.archetypes:maven-archetype-j2ee-simple (An archetype which contains a simplifed sample J2EE application.) 3: internal -> org.apache.maven.archetypes:maven-archetype-plugin (An archetype which contains a sample Maven plugin.) 4: internal -> org.apache.maven.archetypes:maven-archetype-plugin-site (An archetype which contains a sample Maven plugin site. This archetype can be layered upon an existing Maven plugin project.) 5: internal -> org.apache.maven.archetypes:maven-archetype-portlet (An archetype which contains a sample JSR-268 Portlet.) 6: internal -> org.apache.maven.archetypes:maven-archetype-profiles () 7: internal -> org.apache.maven.archetypes:maven-archetype-quickstart (An archetype which contains a sample Maven project.) 8: internal -> org.apache.maven.archetypes:maven-archetype-site (An archetype which contains a sample Maven site which demonstrates some of the supported document types like APT, XDoc, and FML and demonstrates how to i18n your site. This archetype can be layered upon an existing Maven project.) 9: internal -> org.apache.maven.archetypes:maven-archetype-site-simple (An archetype which contains a sample Maven site.) 10: internal -> org.apache.maven.archetypes:maven-archetype-webapp (An archetype which contains a sample Maven Webapp project.) Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 7:
2、輸入任意編號(hào)后,繼續(xù)下載必要jar包,之后要求分別輸入groupId,artifactId,version,package,并確認(rèn)
Define value for property 'groupId': com.aaa Define value for property 'artifactId': bbb Define value for property 'version' 1.0-SNAPSHOT: : 1.0 Define value for property 'package' com.aaa: : project Y: : [INFO] ---------------------------------------------------------------------------- [INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-archetype:1.0 [INFO] ---------------------------------------------------------------------------- [INFO] Parameter: basedir, Value: E:\CODE\test [INFO] Parameter: package, Value: project [INFO] Parameter: groupId, Value: com.aaa [INFO] Parameter: artifactId, Value: bbb [INFO] Parameter: packageName, Value: project [INFO] Parameter: version, Value: 1.0 [INFO] project created from Old (1.x) Archetype in dir: E:\CODE\test\bbb [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 11:12 min [INFO] Finished at: 2017-12-02T22:00:49+08:00 [INFO] Final Memory: 17M/58M [INFO] ------------------------------------------------------------------------
3、瀏覽Maven工程
|-- pom.xml `-- src |-- main | `-- java | `-- com | `-- aaa | `-- bbb | `-- App.java `-- test `-- java `-- com `-- aaa `-- bbb `-- AppTest.java
4、內(nèi)置原型過(guò)多時(shí),可以使用-Dfilter命令過(guò)濾
mvn archetype:generate -Dfilter=j2ee
5、在Maven工程的pom.xml目錄運(yùn)行mvn archetype:create-from-project, 將會(huì)在target/generated-sources/archetype目錄下生成原型工程目錄
6、在原型工程pom.xml文件下,執(zhí)行mvn install來(lái)把原型jar包上傳到本地倉(cāng)庫(kù)
7、這時(shí)的原型就可以使用了,在空目錄執(zhí)行mvn archetype:generate -DarchetypeCatalog=local
mvn archetype:generate -DarchetypeCatalog=local [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Stub Project (No POM) 1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>> [INFO] [INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<< [INFO] [INFO] [INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom --- [INFO] Generating project in Interactive mode [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0) Choose archetype: 1: local -> com.aaa:bbb-archetype (bbb-archetype) Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): :
接下來(lái)就和第一步一樣的流程了。
關(guān)于“如何使用Maven Archetype插件構(gòu)建Maven工程原型模板的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。