```Exception in thread "main" org.apache.flink.table.api.ValidationException: Could not find any factories that implement 'org.apache.flink.table.delegation.ExecutorFactory' in the classpath.
at org.apache.flink.table.factories.FactoryUtil.discoverFactory(FactoryUtil.java:533)
at org.apache.flink.table.api.internal.TableEnvironmentImpl.create(TableEnvironmentImpl.java:278)
at org.apache.flink.table.api.TableEnvironment.create(TableEnvironment.java:93)
at com.kk.MongoDB2.RecommendationSystem.main(RecommendationSystem.java:36)
或者
Exception in thread "main" org.apache.flink.table.api.ValidationException: Could not find any factories that implement 'org.apache.flink.table.factories.FileSystemFormatFactory' in the classpath.
at org.apache.flink.table.factories.FactoryUtil.discoverFactory(FactoryUtil.java:229)
at org.apache.flink.table.filesystem.FileSystemTableFactory.createFormatFactory(FileSystemTableFactory.java:112)
at org.apache.flink.table.filesystem.FileSystemTableSource.getInputFormat(FileSystemTableSource.java:143)
at org.apache.flink.table.filesystem.FileSystemTableSource.getDataStream(FileSystemTableSource.java:127)
at org.apache.flink.table.planner.plan.nodes.physical.PhysicalLegacyTableSourceScan.getSourceTransformation(PhysicalLegacyTableSourceScan.scala:82)
at org.apache.flink.table.planner.plan.nodes.physical.batch.BatchExecLegacyTableSourceScan.translateToPlanInternal(BatchExecLegacyTableSourceScan.scala:95)
at org.apache.flink.table.planner.plan.nodes.physical.batch.BatchExecLegacyTableSourceScan.translateToPlanInternal(BatchExecLegacyTableSourceScan.scala:57)
at org.apache.flink.table.planner.plan.nodes.exec.ExecNode$class.translateToPlan(ExecNode.scala:58)
因为Flink 加载 table Factory 使用的时SPI机制,而正常的flink jar包是不包含META-INF.services 路径的,需要自己去添加
## 方法二 maven 添加插件(推荐)
```js```
<build>
<plugins>
<!-- Java Compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${target.java.version}</source>
<target>${target.java.version}</target>
</configuration>
</plugin>
<!-- We use the maven-shade plugin to create a fat jar that contains all necessary dependencies. -->
<!-- Change the value of <mainClass>...</mainClass> if your program entry point changes. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<!--<transformers combine.children="append">
<!– The service transformer is needed to merge META-INF/services files –>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<!– ... –>
</transformers>-->
<!-- 合并多个connetor 的META-INF.services 文件-->
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>reference.conf</resource>
</transformer>
<!-- The service transformer is needed to merge META-INF/services files -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
<projectName>Apache Flink</projectName>
<encoding>UTF-8</encoding>
</transformer>
</transformers>
<!-- 自动排除不使用的类,缩小jar包体积-->
<!-- <minimizeJar>true</minimizeJar>-->
<artifactSet>
<excludes>
<exclude>org.apache.flink:force-shading</exclude>
<exclude>org.slf4j:*</exclude>
<exclude>org.apache.logging.log4j:*</exclude>
</excludes>
<!--<includes>
<indlude>com.aliyun.openservices:flink-log-connector</indlude>
<indlude>com.alibaba.hologres:hologres-connector-flink-1.12</indlude>
<indlude>com.google.guava:guava</indlude>
<indlude>org.projectlombok:lombok</indlude>
</includes>-->
</artifactSet>
<filters>
<filter>
<!-- Do not copy the signatures in the META-INF folder.
Otherwise, this might cause SecurityExceptions when using the JAR. -->
<artifact>*:*</artifact>
<excludes>
<exclude>module-info.class</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>