Maven使用原型插件来创建项目
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
轉(zhuǎn)自:http://www.yiibai.com/spring/maven_creating_project.html
Maven使用原型插件來(lái)創(chuàng)建項(xiàng)目。要?jiǎng)?chuàng)建一個(gè)簡(jiǎn)單的Java應(yīng)用程序中,我們將使用maven-archetype-quickstart插件。在下面的例子中,我們將創(chuàng)建一個(gè)基于Maven的Java應(yīng)用程序項(xiàng)目在C:\MVN文件夾。
讓我們打開(kāi)命令控制臺(tái),進(jìn)入到C:\MVN目錄并執(zhí)行以下命令mvn命令。
C:\MVN>mvn?archetype:generate -DgroupId=com.companyname.bank? -DartifactId=consumerBanking? -DarchetypeArtifactId=maven-archetype-quickstart? -DinteractiveMode=falseMaven會(huì)開(kāi)始處理,并建立完整的Java應(yīng)用程序項(xiàng)目結(jié)構(gòu)。
INFO]?Scanning?for?projects... [INFO]?Searching?repository?for?plugin?with?prefix:?'archetype'. [INFO]?------------------------------------------------------------------- [INFO]?Building?Maven?Default?Project [INFO]????task-segment:?[archetype:generate]?(aggregator-style) [INFO]?------------------------------------------------------------------- [INFO]?Preparing?archetype:generate [INFO]?No?goals?needed?for?project?-?skipping [INFO]?[archetype:generate?{execution:?default-cli}] [INFO]?Generating?project?in?Batch?mode [INFO]?------------------------------------------------------------------- [INFO]?Using?following?parameters?for?creating?project?from?Old?(1.x)?Archetype:?maven-archetype-quickstart:1.0 [INFO]?------------------------------------------------------------------- [INFO]?Parameter:?groupId,?Value:?com.companyname.bank [INFO]?Parameter:?packageName,?Value:?com.companyname.bank [INFO]?Parameter:?package,?Value:?com.companyname.bank [INFO]?Parameter:?artifactId,?Value:?consumerBanking [INFO]?Parameter:?basedir,?Value:?C:\MVN [INFO]?Parameter:?version,?Value:?1.0-SNAPSHOT [INFO]?project?created?from?Old?(1.x)?Archetype?in?dir:?C:\MVN\consumerBanking [INFO]?------------------------------------------------------------------ [INFO]?BUILD?SUCCESSFUL [INFO]?------------------------------------------------------------------ [INFO]?Total?time:?14?seconds [INFO]?Finished?at:?Tue?Jul?10?15:38:58?IST?2012 [INFO]?Final?Memory:?21M/124M [INFO]?------------------------------------------------------------------現(xiàn)在去到C:/ MVN目錄。將看到創(chuàng)建了一個(gè)Java應(yīng)用程序項(xiàng)目命名consumerBanking(如artifactId規(guī)定)。 Maven使用標(biāo)準(zhǔn)的目錄結(jié)構(gòu)如下圖所示:
用上面的例子中,我們可以了解到以下關(guān)鍵概念
| consumerBanking | contains src folder and pom.xml |
| src/main/java | contains java code files under the package structure (com/companyName/bank). |
| src/main/test | contains test java code files under the package structure (com/companyName/bank). |
| src/main/resources | it contains images/properties files (In above example, we need to create this structure manually). |
Maven還創(chuàng)建了一個(gè)示例Java源文件和Java測(cè)試文件。打開(kāi)C:\MVN\consumerBanking\src\main\java\com\companyname\bank文件夾,會(huì)看到App.java。
package?com.companyname.bank;/***?Hello?world!**/public?class?App?{public?static?void?main(?String[]?args?){System.out.println(?"Hello?World!"?);}}打開(kāi) C:\MVN\consumerBanking\src\test\java\com\companyname\bank 文件夾, 你會(huì)看到 AppTest.java.
package?com.companyname.bank;import?junit.framework.Test;import?junit.framework.TestCase;import?junit.framework.TestSuite;/***?Unit?test?for?simple?App.*/public?class?AppTest?extends?TestCase?{/***?Create?the?test?case**?@param?testName?name?of?the?test?case*/public?AppTest(?String?testName?){super(?testName?);}/***?@return?the?suite?of?tests?being?tested*/public?static?Test?suite(){return?new?TestSuite(?AppTest.class?);}/***?Rigourous?Test?:-)*/public?void?testApp(){assertTrue(?true?);}}開(kāi)發(fā)人員把他們的文件在提到上述表格和Maven處理所有構(gòu)建相關(guān)的復(fù)雜性。
在下一節(jié)中,我們將討論如何使用Maven來(lái)構(gòu)建和測(cè)試項(xiàng)目:Maven構(gòu)建和測(cè)試項(xiàng)目.
轉(zhuǎn)載于:https://my.oschina.net/u/589247/blog/187310
總結(jié)
以上是生活随笔為你收集整理的Maven使用原型插件来创建项目的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: goaccess-nginx日志分析工具
- 下一篇: Devexpress Barmanage