我正在尝试使用 Flink 1.5.0 创建一个面向批处理的 Flink 作业,并希望使用 Table 和 SQL API 来处理数据。我的问题是尝试创建 BatchTableEnviroment 我收到编译错误
BatchJob.java:[46,73] 无法访问 org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
造成于
final BatchTableEnvironment bTableEnv = TableEnvironment.getTableEnvironment(bEnv);
据我所知,我不依赖流媒体环境。我的代码如下所示。
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.TableEnvironment;
import org.apache.flink.table.api.java.BatchTableEnvironment;
import org.apache.flink.table.sources.CsvTableSource;
import org.apache.flink.table.sources.TableSource;
import java.util.Date;
public class BatchJob {
public static void main(String[] args) throws Exception {
final ExecutionEnvironment bEnv = ExecutionEnvironment.getExecutionEnvironment();
// create a TableEnvironment for batch queries
final BatchTableEnvironment bTableEnv = TableEnvironment.getTableEnvironment(bEnv);
... do stuff
// execute program
bEnv.execute("MY Batch Jon");
}
我的 pom 依赖项如下
<dependencies>
<!-- Apache Flink dependencies -->
<!-- These dependencies are provided, because they should not be packaged into the JAR file. -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table_2.11</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-scala_2.11</artifactId>
<version>${flink.version}</version>
</dependency>
<!-- Add connector dependencies here. They must be in the default scope (compile). -->
<!-- Example:
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-kafka-0.10_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
-->
<!-- Add logging framework, to produce console output when running in the IDE. -->
<!-- These dependencies are excluded from the application JAR by default. -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>runtime</scope>
</dependency>
</dependencies>
请有人可以帮助我了解 Streaming API 的依赖关系是什么以及为什么我需要它来进行批处理作业?非常感谢您的帮助。奥利弗