-
正常情况下,即使安装好了Scala和IDEA scala插件,我们新建的maven项目,IDEA不会出现新建scala的选项 要想IDEA自动有这个选项还需要在Pom.xml引入build插件
<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
import org.apache.flink.api.scala.ExecutionEnvironment
//不引用这个下面的代码会报错No implicits found for parameter evidence$11: TypeInformation[String]
import org.apache.flink.api.scala._
/**
* @Auther: GuiRunning
* @Date: 2019/1/25 22:35
* @Description:
*/
object WordCountJava {
def main(args: Array[String]): Unit = {
val env = ExecutionEnvironment.getExecutionEnvironment
val lines = env.readTextFile("/test.txt");
val c = lines.flatMap(x=>x.split("\\W+"))
.map(x=>Tuple2(x,1)).groupBy(0).sum(1).print()
}
}
网友评论