<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java</artifactId>
<version>1.8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_2.11</artifactId>
<version>1.8.0</version>
<scope>provided</scope>
</dependency>
在这里,scope设置成了provided,满足编译和运行,但不满足测试,如果在打包成jar包去运行的时候,需要改成compile
下面是将Kafka 0.10的连接器添加为依赖项(Maven语法)的示例:
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-kafka-0.10_2.11</artifactId>
<version>1.8.0</version>
</dependency>
重要:对于Maven(和其他构建工具)将依赖项正确打包到应用程序jar中,必须在范围compile中指定这些应用程序依赖项(与核心依赖项不同,核心依赖项必须在提供provided作用域中指定)。
只使用Java的开发人员可以选择任何Scala版本,Scala开发人员需要选择与其应用程序的Scala版本匹配的Scala版本。
一般规则:永远不必将Hadoop依赖项直接添加到您的应用程序中。 (唯一的例外是当使用现有的Hadoop输入/输出格式与Flink的Hadoop兼容包装器时)
附录:用于构建具有依赖关系的Jar的模板
构建包含声明的连接器和库所需的所有依赖项的应用程序JAR,可以使用以下shade插件定义:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>com.google.code.findbugs:jsr305</exclude>
<exclude>org.slf4j:*</exclude>
<exclude>log4j:*</exclude>
</excludes>
</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>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>my.programs.main.clazz</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- igat.cn 版权所有 赣ICP备2024042791号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务