我正在通过this Apache Flink training创建一个简单的应用程序来从文件中读取数据并对其进行过滤。我使用Scala作为编写Flink应用程序的语言,最终代码如下所示:
package com.dataartisans.flinktraining.exercises.datastream_scala.basics
import com.dataartisans.flinktraining.exercises.datastream_java.sources.TaxiRideSource
import com.dataartisans.flinktraining.exercises.datastream_java.utils.GeoUtils
import org.apache.flink.api.java.utils.ParameterTool
import org.apache.flink.streaming.api.TimeCharacteristic
import org.apache.flink.streaming.api.scala._
object RideCleansing {
def main(args: Array[String]) {
val params = ParameterTool.fromArgs(args)
val input = params.getRequired("input")
val maxDelay = 60
val speed = 600
val env = StreamExecutionEnvironment.getExecutionEnvironment
env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime)
val rides = env.addSource(new TaxiRideSource(input, maxDelay, speed))
val filteredRides = rides
.filter(r => GeoUtils.isInNYC(r.startLon, r.startLat) && GeoUtils.isInNYC(r.endLon, r.endLat))
filteredRides.print()
env.execute("Taxi Ride Cleansing")
}
}
根据建议here,我已将以下内容添加到我的POM文件中:
<dependency>
<groupId>com.data-artisans</groupId>
<artifactId>flink-training-exercises</artifactId>
<version>0.10.0</version>
</dependency>
但是,当我输入maven clean package
时,我收到以下错误:
error: object dataartisans is not a member of package com
import com.dataartisans.flinktraining.exercises.datastream_java.sources.TaxiRideSource
它似乎正在寻找包com.dataartisans
,但是它被导入为带有连字符的com.data-artisans
,因此无法找到它。如果我的主IDE是IntelliJ,我该如何解决这个问题?
以下是package
命令的输出:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Flink Quickstart Job 0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ flink-scala-project ---
[INFO] Deleting /da-flink/target
[INFO]
[INFO] --- build-helper-maven-plugin:1.7:add-source (add-source) @ flink-scala-project ---
[INFO] Source directory: /da-flink/src/main/scala added.
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ flink-scala-project ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 6 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ flink-scala-project ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- scala-maven-plugin:3.2.2:compile (default) @ flink-scala-project ---
[WARNING] Expected all dependencies to require Scala version: 2.10.4
[WARNING] org.scala-lang:scala-reflect:2.10.4 requires scala version: 2.10.4
[WARNING] org.apache.flink:flink-scala_2.10:1.3.0 requires scala version: 2.10.4
[WARNING] org.apache.flink:flink-scala_2.10:1.3.0 requires scala version: 2.10.4
[WARNING] org.scala-lang:scala-compiler:2.10.4 requires scala version: 2.10.4
[WARNING] org.scalamacros:quasiquotes_2.10:2.0.1 requires scala version: 2.10.4
[WARNING] org.apache.flink:flink-streaming-scala_2.10:1.3.0 requires scala version: 2.10.4
[WARNING] org.apache.flink:flink-streaming-scala_2.10:1.3.0 requires scala version: 2.10.4
[WARNING] org.apache.flink:flink-runtime_2.10:1.3.0 requires scala version: 2.10.4
[WARNING] com.data-artisans:flakka-actor_2.10:2.3-custom requires scala version: 2.10.4
[WARNING] com.data-artisans:flakka-remote_2.10:2.3-custom requires scala version: 2.10.4
[WARNING] com.data-artisans:flakka-slf4j_2.10:2.3-custom requires scala version: 2.10.4
[WARNING] org.clapper:grizzled-slf4j_2.10:1.0.2 requires scala version: 2.10.3
[WARNING] Multiple versions of scala libraries detected!
[INFO] /da-flink/src/main/scala:-1: info: compiling
[INFO] Compiling 5 source files to /da-flink/target/classes at 1498877506263
[ERROR] /da-flink/src/main/scala/org/apache/flink/quickstart/RideCleansing.scala:21: error: object dataartisans is not a member of package com
[ERROR] import com.dataartisans.flinktraining.exercises.datastream_java.sources.TaxiRideSource
[ERROR] ^
[ERROR] /da-flink/src/main/scala/org/apache/flink/quickstart/RideCleansing.scala:22: error: object dataartisans is not a member of package com
[ERROR] import com.dataartisans.flinktraining.exercises.datastream_java.utils.GeoUtils
[ERROR] ^
[ERROR] /da-flink/src/main/scala/org/apache/flink/quickstart/RideCleansing.scala:61: error: not found: type TaxiRideSource
[ERROR] val rides = env.addSource(new TaxiRideSource(input, maxDelay, servingSpeed))
[ERROR] ^
[ERROR] three errors found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.077 s
[INFO] Finished at: 2017-06-30T22:51:48-04:00
[INFO] Final Memory: 15M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.2.2:compile (default) on project flink-scala-project: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
答案 0 :(得分:2)
groupId
,artifactId
和version
(又名 GAV )是Maven coordinates,对于识别工件至关重要(jar
)逻辑上(在POM中)和物理上(在存储库中)。这与工件内的包或工件中的类文件内的导入无关。 GAV可以从存储库访问它们以构建适当的类路径。所以&#34; 但导入为com.data-artisans
&#34;在这方面不是一个正确的陈述。因此,问题必须在其他地方,但在Maven。
BTW,在哪个构建阶段发生错误?我想它是compile
,是吗?提供更多相关的构建输出行通常会使事情变得更加清晰。
你从哪里获得版本0.10.0
?它在Maven Central处不可用。我建议试试版0.6
。
答案 1 :(得分:2)
答案结果非常简单:我将依赖项放在pom文件的错误部分,并将另一组依赖项作为概要文件的一部分。粗心的错误......