IDEA 环境下Scala 和 Java 混合开发(Tips)

2019-01-25  本文已影响0人  ggr
 <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()
  }
}
上一篇下一篇

猜你喜欢

热点阅读