flink source fromCollection source

import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment}
import org.apache.flink.api.scala._

object FlinkDemo03_CommonSource_fromEle {
    
    case class Student(name: String, age: Int)
    
    def main(args: Array[String]): Unit = {
        //1 创建环境
        val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
        //2 读取数据
        val ds: DataStream[Student] = env.fromCollection(List(Student("jack", 20), Student("rose", 18)))
        //3 计算
        ds.print()
        
        //4 执行
        env.execute()
    }
}

 

你可能感兴趣的:(flink source fromCollection source)