温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么构建maven工程

发布时间:2021-08-16 10:39:27 来源:亿速云 阅读:91 作者:chen 栏目:大数据

本篇内容介绍了“怎么构建maven工程”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

1,要求

Maven 3.0.4以上版本

Java 7.x以上版本

2,构建maven工程

mvn archetype:generate                               \
-DarchetypeGroupId=org.apache.flink              \
-DarchetypeArtifactId=flink-quickstart-scala     \
-DarchetypeVersion=1.3.2

允许你重新给你的工程命名,执行该命令后需要输入groupId, artifactId, and package名。

3,检查导入项目

可以在生成的目录下查看工程目录结构

怎么构建maven工程

可以将该maven工程导入你的IDE编辑器。对于Eclipse,需要下面的几个插件,可以在线安装。

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直接导入maven工程,然后引入scala插件即可。

4,运行测试

浪尖习惯用idea作为,导入工程后,可以看到

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中运行,执行结果如下:

怎么构建maven工程

“怎么构建maven工程”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI