Reputation: 6342
I am using following script to submit flink application,
flink run -m yarn-cluster -c com.my.flink.learningflink.FlinkToMySQL -yn 4 -ys 1 -j /tmp/learing.flink.1.7.1-0.1.jar
My class FlinkToMySQL is in learing.flink.1.7.1-0.1.jar, but my application also needs to depend on mysql jar, how could I specify the mysql jar and other dependent jars.
Also, I tried the -yt
option with following script
flink run -m yarn-cluster -c com.my.flink.learningflink.FlinkToMySQL -yn 4 -ys 1 -yt /tmp/mysql-connector-java-5.1.45.jar -j /tmp/learing.flink.1.7.1-0.1.jar
,it still complains that no suitable driver found(runs well in my local IDE).
Thanks.
Upvotes: 1
Views: 755
Reputation: 13346
In general, Flink supports multiple ways to ship user code jars:
FLINK_HOME/lib
which is shipped to the cluster-yt
to specify additional files which should be shipped to the cluster and are added to the system's classpathUpvotes: 1
Reputation: 16392
Build your jar with maven as a "jar with dependencies" and deploy that jar instead.
My maven build definition looks like this:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Upvotes: 0