Flink SQL 創建 TableEnvironment 對象失敗

Flink新手在使用示例創建  TableEnvironment 或者 StreamTableEnvironment 對象時(IFDE環境下),很有可能會遇到如下錯誤:

Exception in thread "main" org.apache.flink.table.api.NoMatchingTableFactoryException: Could not find a suitable table factory for 'org.apache.flink.table.delegation.ExecutorFactory' in the classpath.

Reason: No factory implements 'org.apache.flink.table.delegation.ExecutorFactory'.

解決辦法如下:

打開項目的pom.xml文件,對照  flink-table-planner-blink_XXX, 修改其屬性標籤 .

            <groupId>org.apache.flink</groupId>
            <artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
            <version>${flink.version}</version>
            <!-- <scope>provided</scope> -->

刪除或註釋掉   <scope>provided</scope> 標籤.

 

  • compile

    This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.(Compile means that you need the JAR for compiling and running the app. For a web application, as an example, the JAR will be placed in the WEB-INF/lib directory.)

  • provided

    This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.(Provided means that you need the JAR for compiling, but at run time there is already a JAR provided by the environment so you don't need it packaged with your app. For a web app, this means that the JAR file will not be placed into the WEB-INF/lib directory.)

For a web app, if the app server already provides the JAR (or its functionality), then use "provided" otherwise use "compile".

發佈了68 篇原創文章 · 獲贊 161 · 訪問量 141萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章