Apache Flink导入scalaapi流扩展


0

我尝试导入apacheflink的scalaapi流扩展,如中所述https://ci.apache.org/projects/flink/flink-docs-master/api/scala_api_extensions.html

但是,我的ScalaIDE抱怨以下消息:

我使用的是Scala2.11和Flink1.0.1。

这是我的进口声明:

这是我的pom.xml文件:

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

&lt;groupId&gt;org.myorg.quickstart&lt;/groupId&gt;
&lt;artifactId&gt;quickstart&lt;/artifactId&gt;
&lt;version&gt;0.1&lt;/version&gt;
&lt;packaging&gt;jar&lt;/packaging&gt;

&lt;name&gt;Flink Quickstart Job&lt;/name&gt;
&lt;url&gt;http://www.myorganization.org&lt;/url&gt;

&lt;repositories&gt;
    &lt;repository&gt;
        &lt;id&gt;apache.snapshots&lt;/id&gt;
        &lt;name&gt;Apache Development Snapshot Repository&lt;/name&gt;
        &lt;url&gt;https://repository.apache.org/content/repositories/snapshots/&lt;/url&gt;
        &lt;releases&gt;
            &lt;enabled&gt;false&lt;/enabled&gt;
        &lt;/releases&gt;
        &lt;snapshots&gt;
            &lt;enabled&gt;true&lt;/enabled&gt;
        &lt;/snapshots&gt;
    &lt;/repository&gt;
&lt;/repositories&gt;

&lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;flink.version&gt;1.0.1&lt;/flink.version&gt;
&lt;/properties&gt;

&lt;!-- 

    Execute "mvn clean package -Pbuild-jar"
    to build a jar file out of this project!

    How to use the Flink Quickstart pom:

    a) Adding new dependencies:
        You can add dependencies to the list below.
        Please check if the maven-shade-plugin below is filtering out your dependency
        and remove the exclude from there.

    b) Build a jar for running on the cluster:
        There are two options for creating a jar from this project

        b.1) "mvn clean package" -&gt; this will create a fat jar which contains all
                dependencies necessary for running the jar created by this pom in a cluster.
                The "maven-shade-plugin" excludes everything that is provided on a running Flink cluster.

        b.2) "mvn clean package -Pbuild-jar" -&gt; This will also create a fat-jar, but with much
                nicer dependency exclusion handling. This approach is preferred and leads to
                much cleaner jar files.
--&gt;

&lt;dependencies&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.apache.flink&lt;/groupId&gt;
        &lt;artifactId&gt;flink-scala_2.11&lt;/artifactId&gt;
        &lt;version&gt;${flink.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.apache.flink&lt;/groupId&gt;
        &lt;artifactId&gt;flink-streaming-scala_2.11&lt;/artifactId&gt;
        &lt;version&gt;${flink.version}&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.apache.flink&lt;/groupId&gt;
        &lt;artifactId&gt;flink-clients_2.11&lt;/artifactId&gt;
        &lt;version&gt;${flink.version}&lt;/version&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;

&lt;profiles&gt;
    &lt;profile&gt;
        &lt;!-- Profile for packaging correct JAR files --&gt;
        &lt;id&gt;build-jar&lt;/id&gt;
        &lt;activation&gt;
            &lt;activeByDefault&gt;false&lt;/activeByDefault&gt;
        &lt;/activation&gt;
        &lt;dependencies&gt;
            &lt;dependency&gt;
                &lt;groupId&gt;org.apache.flink&lt;/groupId&gt;
                &lt;artifactId&gt;flink-scala_2.10&lt;/artifactId&gt;
                &lt;version&gt;${flink.version}&lt;/version&gt;
                &lt;scope&gt;provided&lt;/scope&gt;
            &lt;/dependency&gt;
            &lt;dependency&gt;
                &lt;groupId&gt;org.apache.flink&lt;/groupId&gt;
                &lt;artifactId&gt;flink-streaming-scala_2.10&lt;/artifactId&gt;
                &lt;version&gt;${flink.version}&lt;/version&gt;
                &lt;scope&gt;provided&lt;/scope&gt;
            &lt;/dependency&gt;
            &lt;dependency&gt;
                &lt;groupId&gt;org.apache.flink&lt;/groupId&gt;
                &lt;artifactId&gt;flink-clients_2.10&lt;/artifactId&gt;
                &lt;version&gt;${flink.version}&lt;/version&gt;
                &lt;scope&gt;provided&lt;/scope&gt;
            &lt;/dependency&gt;
        &lt;/dependencies&gt;

        &lt;build&gt;
            &lt;plugins&gt;
                &lt;!-- disable the exclusion rules --&gt;
                &lt;plugin&gt;
                    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                    &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
                    &lt;version&gt;2.4.1&lt;/version&gt;
                    &lt;executions&gt;
                        &lt;execution&gt;
                            &lt;phase&gt;package&lt;/phase&gt;
                            &lt;goals&gt;
                                &lt;goal&gt;shade&lt;/goal&gt;
                            &lt;/goals&gt;
                            &lt;configuration&gt;
                                &lt;artifactSet&gt;
                                    &lt;excludes combine.self="override"&gt;&lt;/excludes&gt;
                                &lt;/artifactSet&gt;
                            &lt;/configuration&gt;
                        &lt;/execution&gt;
                    &lt;/executions&gt;
                &lt;/plugin&gt;
            &lt;/plugins&gt;
        &lt;/build&gt;
    &lt;/profile&gt;
&lt;/profiles&gt;

&lt;!-- We use the maven-assembly plugin to create a fat jar that contains all dependencies
    except flink and its transitive dependencies. The resulting fat-jar can be executed
    on a cluster. Change the value of Program-Class if your program entry point changes. --&gt;
&lt;build&gt;
    &lt;plugins&gt;
        &lt;!-- We use the maven-shade plugin to create a fat jar that contains all dependencies
        except flink and it's transitive dependencies. The resulting fat-jar can be executed
        on a cluster. Change the value of Program-Class if your program entry point changes. --&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.4.1&lt;/version&gt;
            &lt;executions&gt;
                &lt;!-- Run shade goal on package phase --&gt;
                &lt;execution&gt;
                    &lt;phase&gt;package&lt;/phase&gt;
                    &lt;goals&gt;
                        &lt;goal&gt;shade&lt;/goal&gt;
                    &lt;/goals&gt;
                    &lt;configuration&gt;
                        &lt;artifactSet&gt;
                            &lt;excludes&gt;
                                &lt;!-- This list contains all dependencies of flink-dist
                                Everything else will be packaged into the fat-jar
                                --&gt;
                                &lt;exclude&gt;org.apache.flink:flink-annotations&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.flink:flink-shaded-hadoop1&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.flink:flink-shaded-hadoop2&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.flink:flink-shaded-curator-recipes&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.flink:flink-core&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.flink:flink-java&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.flink:flink-scala_2.10&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.flink:flink-runtime_2.10&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.flink:flink-optimizer_2.10&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.flink:flink-clients_2.10&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.flink:flink-avro_2.10&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.flink:flink-examples-batch_2.10&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.flink:flink-examples-streaming_2.10&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.flink:flink-streaming-java_2.10&lt;/exclude&gt;

                                &lt;!-- Also exclude very big transitive dependencies of Flink

                                WARNING: You have to remove these excludes if your code relies on other
                                versions of these dependencies.

                                --&gt;

                                &lt;exclude&gt;org.scala-lang:scala-library&lt;/exclude&gt;
                                &lt;exclude&gt;org.scala-lang:scala-compiler&lt;/exclude&gt;
                                &lt;exclude&gt;org.scala-lang:scala-reflect&lt;/exclude&gt;
                                &lt;exclude&gt;com.amazonaws:aws-java-sdk&lt;/exclude&gt;
                                &lt;exclude&gt;com.typesafe.akka:akka-actor_*&lt;/exclude&gt;
                                &lt;exclude&gt;com.typesafe.akka:akka-remote_*&lt;/exclude&gt;
                                &lt;exclude&gt;com.typesafe.akka:akka-slf4j_*&lt;/exclude&gt;
                                &lt;exclude&gt;io.netty:netty-all&lt;/exclude&gt;
                                &lt;exclude&gt;io.netty:netty&lt;/exclude&gt;
                                &lt;exclude&gt;commons-fileupload:commons-fileupload&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.avro:avro&lt;/exclude&gt;
                                &lt;exclude&gt;commons-collections:commons-collections&lt;/exclude&gt;
                                &lt;exclude&gt;com.thoughtworks.paranamer:paranamer&lt;/exclude&gt;
                                &lt;exclude&gt;org.xerial.snappy:snappy-java&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.commons:commons-compress&lt;/exclude&gt;
                                &lt;exclude&gt;org.tukaani:xz&lt;/exclude&gt;
                                &lt;exclude&gt;com.esotericsoftware.kryo:kryo&lt;/exclude&gt;
                                &lt;exclude&gt;com.esotericsoftware.minlog:minlog&lt;/exclude&gt;
                                &lt;exclude&gt;org.objenesis:objenesis&lt;/exclude&gt;
                                &lt;exclude&gt;com.twitter:chill_*&lt;/exclude&gt;
                                &lt;exclude&gt;com.twitter:chill-java&lt;/exclude&gt;
                                &lt;exclude&gt;com.twitter:chill-avro_*&lt;/exclude&gt;
                                &lt;exclude&gt;com.twitter:chill-bijection_*&lt;/exclude&gt;
                                &lt;exclude&gt;com.twitter:bijection-core_*&lt;/exclude&gt;
                                &lt;exclude&gt;com.twitter:bijection-avro_*&lt;/exclude&gt;
                                &lt;exclude&gt;commons-lang:commons-lang&lt;/exclude&gt;
                                &lt;exclude&gt;junit:junit&lt;/exclude&gt;
                                &lt;exclude&gt;de.javakaffee:kryo-serializers&lt;/exclude&gt;
                                &lt;exclude&gt;joda-time:joda-time&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.commons:commons-lang3&lt;/exclude&gt;
                                &lt;exclude&gt;org.slf4j:slf4j-api&lt;/exclude&gt;
                                &lt;exclude&gt;org.slf4j:slf4j-log4j12&lt;/exclude&gt;
                                &lt;exclude&gt;log4j:log4j&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.commons:commons-math&lt;/exclude&gt;
                                &lt;exclude&gt;org.apache.sling:org.apache.sling.commons.json&lt;/exclude&gt;
                                &lt;exclude&gt;commons-logging:commons-logging&lt;/exclude&gt;
                                &lt;exclude&gt;commons-codec:commons-codec&lt;/exclude&gt;
                                &lt;exclude&gt;com.fasterxml.jackson.core:jackson-core&lt;/exclude&gt;
                                &lt;exclude&gt;com.fasterxml.jackson.core:jackson-databind&lt;/exclude&gt;
                                &lt;exclude&gt;com.fasterxml.jackson.core:jackson-annotations&lt;/exclude&gt;
                                &lt;exclude&gt;stax:stax-api&lt;/exclude&gt;
                                &lt;exclude&gt;com.typesafe:config&lt;/exclude&gt;
                                &lt;exclude&gt;org.uncommons.maths:uncommons-maths&lt;/exclude&gt;
                                &lt;exclude&gt;com.github.scopt:scopt_*&lt;/exclude&gt;
                                &lt;exclude&gt;commons-io:commons-io&lt;/exclude&gt;
                                &lt;exclude&gt;commons-cli:commons-cli&lt;/exclude&gt;
                            &lt;/excludes&gt;
                        &lt;/artifactSet&gt;
                        &lt;filters&gt;
                            &lt;filter&gt;
                                &lt;artifact&gt;org.apache.flink:*&lt;/artifact&gt;
                                &lt;excludes&gt;
                                    &lt;!-- exclude shaded google but include shaded curator --&gt;
                                    &lt;exclude&gt;org/apache/flink/shaded/com/**&lt;/exclude&gt;
                                    &lt;exclude&gt;web-docs/**&lt;/exclude&gt;
                                &lt;/excludes&gt;
                            &lt;/filter&gt;
                            &lt;filter&gt;
                                &lt;!-- Do not copy the signatures in the META-INF folder.
                                Otherwise, this might cause SecurityExceptions when using the JAR. --&gt;
                                &lt;artifact&gt;*:*&lt;/artifact&gt;
                                &lt;excludes&gt;
                                    &lt;exclude&gt;META-INF/*.SF&lt;/exclude&gt;
                                    &lt;exclude&gt;META-INF/*.DSA&lt;/exclude&gt;
                                    &lt;exclude&gt;META-INF/*.RSA&lt;/exclude&gt;
                                &lt;/excludes&gt;
                            &lt;/filter&gt;
                        &lt;/filters&gt;
                        &lt;transformers&gt;
                            &lt;!-- add Main-Class to manifest file --&gt;
                            &lt;transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"&gt;
                                &lt;mainClass&gt;org.myorg.quickstart.Job&lt;/mainClass&gt;
                            &lt;/transformer&gt;
                        &lt;/transformers&gt;
                        &lt;createDependencyReducedPom&gt;false&lt;/createDependencyReducedPom&gt;
                    &lt;/configuration&gt;
                &lt;/execution&gt;
            &lt;/executions&gt;
        &lt;/plugin&gt;

        &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.1&lt;/version&gt;
            &lt;configuration&gt;
                &lt;source&gt;1.7&lt;/source&gt;
                &lt;target&gt;1.7&lt;/target&gt;
            &lt;/configuration&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;net.alchim31.maven&lt;/groupId&gt;
            &lt;artifactId&gt;scala-maven-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.1.4&lt;/version&gt;
            &lt;executions&gt;
                &lt;execution&gt;
                    &lt;goals&gt;
                        &lt;goal&gt;compile&lt;/goal&gt;
                        &lt;goal&gt;testCompile&lt;/goal&gt;
                    &lt;/goals&gt;
                &lt;/execution&gt;
            &lt;/executions&gt;
        &lt;/plugin&gt;

        &lt;!-- Eclipse Integration --&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-eclipse-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.8&lt;/version&gt;
            &lt;configuration&gt;
                &lt;downloadSources&gt;true&lt;/downloadSources&gt;
                &lt;projectnatures&gt;
                    &lt;projectnature&gt;org.scala-ide.sdt.core.scalanature&lt;/projectnature&gt;
                    &lt;projectnature&gt;org.eclipse.jdt.core.javanature&lt;/projectnature&gt;
                &lt;/projectnatures&gt;
                &lt;buildcommands&gt;
                    &lt;buildcommand&gt;org.scala-ide.sdt.core.scalabuilder&lt;/buildcommand&gt;
                &lt;/buildcommands&gt;
                &lt;classpathContainers&gt;
                    &lt;classpathContainer&gt;org.scala-ide.sdt.launching.SCALA_CONTAINER
                    &lt;/classpathContainer&gt;
                    &lt;classpathContainer&gt;org.eclipse.jdt.launching.JRE_CONTAINER
                    &lt;/classpathContainer&gt;
                &lt;/classpathContainers&gt;
                &lt;excludes&gt;
                    &lt;exclude&gt;org.scala-lang:scala-library&lt;/exclude&gt;
                    &lt;exclude&gt;org.scala-lang:scala-compiler&lt;/exclude&gt;
                &lt;/excludes&gt;
                &lt;sourceIncludes&gt;
                    &lt;sourceInclude&gt;**/*.scala&lt;/sourceInclude&gt;
                    &lt;sourceInclude&gt;**/*.java&lt;/sourceInclude&gt;
                &lt;/sourceIncludes&gt;
            &lt;/configuration&gt;
        &lt;/plugin&gt;

        &lt;!-- Adding scala source directories to build path --&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
            &lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt;
            &lt;version&gt;1.7&lt;/version&gt;
            &lt;executions&gt;
                &lt;!-- Add src/main/scala to eclipse build path --&gt;
                &lt;execution&gt;
                    &lt;id&gt;add-source&lt;/id&gt;
                    &lt;phase&gt;generate-sources&lt;/phase&gt;
                    &lt;goals&gt;
                        &lt;goal&gt;add-source&lt;/goal&gt;
                    &lt;/goals&gt;
                    &lt;configuration&gt;
                        &lt;sources&gt;
                            &lt;source&gt;src/main/scala&lt;/source&gt;
                        &lt;/sources&gt;
                    &lt;/configuration&gt;
                &lt;/execution&gt;
                &lt;!-- Add src/test/scala to eclipse build path --&gt;
                &lt;execution&gt;
                    &lt;id&gt;add-test-source&lt;/id&gt;
                    &lt;phase&gt;generate-test-sources&lt;/phase&gt;
                    &lt;goals&gt;
                        &lt;goal&gt;add-test-source&lt;/goal&gt;
                    &lt;/goals&gt;
                    &lt;configuration&gt;
                        &lt;sources&gt;
                            &lt;source&gt;src/test/scala&lt;/source&gt;
                        &lt;/sources&gt;
                    &lt;/configuration&gt;
                &lt;/execution&gt;
            &lt;/executions&gt;
        &lt;/plugin&gt;
    &lt;/plugins&gt;
&lt;/build&gt;

</project>

1 答案


0

从1.1版开始,scalaapi扩展只是Flink的一部分。因此,为了 test它们,您现在必须使用version1.1-SNAPSHOT。


我来回答

写文章

提问题

面试题