您好,登錄后才能下訂單哦!
本篇內(nèi)容介紹了“怎么構(gòu)建maven工程”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
1,要求
Maven 3.0.4以上版本
Java 7.x以上版本
2,構(gòu)建maven工程
mvn archetype:generate \
-DarchetypeGroupId=org.apache.flink \
-DarchetypeArtifactId=flink-quickstart-scala \
-DarchetypeVersion=1.3.2
允許你重新給你的工程命名,執(zhí)行該命令后需要輸入groupId, artifactId, and package名。
3,檢查導(dǎo)入項(xiàng)目
可以在生成的目錄下查看工程目錄結(jié)構(gòu)
可以將該maven工程導(dǎo)入你的IDE編輯器。對(duì)于Eclipse,需要下面的幾個(gè)插件,可以在線(xiàn)安裝。
1),Eclipse 4.x
a) Scala IDE : http://download.scala-ide.org/sdk/lithium/e44/scala211/stable/site
b) m2eclipse-scala : http://alchim31.free.fr/m2e-scala/update-site
c) BuildHelper Maven Plugin :
https://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-buildhelper/0.15.0/N/0.15.0.201207090124/
2),Eclipse 3.8
a) Scala IDE for Scala 2.11 :
http://download.scala-ide.org/sdk/helium/e38/scala211/stable/site
Scala IDE for Scala 2.10 :
http://download.scala-ide.org/sdk/helium/e38/scala210/stable/site
b) m2eclipse-scala :
http://alchim31.free.fr/m2e-scala/update-site
c)Build Helper Maven Plugin
https://repository.sonatype.org/content/repositories/forge-sites/m2e-extras/0.14.0/N/0.14.0.201109282148/
IntelliJ IDE直接導(dǎo)入maven工程,然后引入scala插件即可。
4,運(yùn)行測(cè)試
浪尖習(xí)慣用idea作為,導(dǎo)入工程后,可以看到
object WordCount {
def main(args: Array[String]) {
// set up the execution environment
val env = ExecutionEnvironment.getExecutionEnvironment
// get input data
val text = env.fromElements("To be, or not to be,--that is the question:--",
"Whether 'tis nobler in the mind to suffer", "The slings and arrows of outrageous fortune",
"Or to take arms against a sea of troubles,")
val counts = text.flatMap { _.toLowerCase.split("\\W+") }
.map { (_, 1) }
.groupBy(0)
.sum(1)
// execute and print result
counts.print()
}
}
直接可以在idea中運(yùn)行,執(zhí)行結(jié)果如下:
“怎么構(gòu)建maven工程”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
免責(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)容。